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());
精彩评论