开发者

How to set the File Info

开发者 https://www.devze.com 2023-03-19 03:25 出处:网络
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;

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

精彩评论

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

关注公众号