file exists bugs


dear all,

i have below code. don't know why file.exists return false?? have checked exists.

string path = system.io.path.getdirectoryname(
      system.reflection.assembly.getexecutingassembly().getname().codebase);

               if (file.exists(path + @"\" + dcfile))  /// not exists???

                                                                      //path="file:\c:\program files\......................
                {
                    using (streamreader reader = new streamreader(path + @"\" + dcfile, encoding.ascii))

raymond,

the codebase property returns url of path string. because of see "file:\" in front of path. call string.substring() method path behind "file:\".


hannes

if have got questions this, ask.

in perfect world,
users never enter data in wrong form,
files choose open exist
, code never have bugs.

c# vb.net: http://www.developerfusion.com/tools/convert/csharp-to-vb/



Visual Studio Languages  ,  .NET Framework  >  Visual C#



Comments

Popular posts from this blog

Azure DocumentDB Owner resource does not exist

BizTalk Server 2013 Azure VM Log Shipping and HA for hosts

How to Share webservice object to all user