开发者

Fileinfo - c# Vs2008

Can I use FileInfo as such:

 FileInfo fileInfo = new FileInfo(@"\\mymachine\downloads\;\\yourmachine\Log\" +  "11.txt");
StreamWriter sw = fileInfo.CreateText();
sw.WriteLine("write some data");
sw.Close();

My lead thinks it can be used as such but I get an exception when I run that 开发者_如何学Ccode..

Exception:

System.IO.DirectoryNotFoundException Could not find a part of the path

He thinks he can do a fake load balance and/or depending on which share is available the code will place an order file to be processed. I do not agree with his thinking but he my boss and i gotta do his biding..


The FileInfo constructor takes the path to a single file; what you're passing it is not a valid file name, so I'd expect an ArgumentException. What are you actually trying to accomplish here?


FileInfo just doesn't work like that. You're going to have to use something like File.Exists to see which file is available and then write code to write to one share or the other.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜