开发者

How to set the File Info

I am writing this below code in my C# project. I am getting the following error:

The best overloaded method match for System.IO.File.FileInfo has some invalid arguments;

Whether the code is correct or n开发者_如何学Cot.

FileInfo file = new FileInfo(ViewState["value"]);

Thanks in advance


My guess is that you just need to cast to string:

FileInfo file = new FileInfo((string) ViewState["value"]);

Basically ViewState[string] returns an object, and there's no FileInfo(object) constructor - that's what the compiler was complaining about.


You could do

FileInfo file = new FileInfo(ViewState["value"].ToString()); 
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜