Hello, I have a string in C#
String file="\\mserver-80\docs\somedoc.doc"
Now How do I get fileInfo from the above sting. What I mean is, I want to declare something like
FileInfo fInfo = new FileInfo(file);
fileExtn = fInfo.Extension;
Hello, I have a string in C#
String file="\\mserver-80\docs\somedoc.doc"
Now How do I get fileInfo from the above sting. What I mean is, I want to declare something like
FileInfo fInfo = new FileInfo(file);
fileExtn = fInfo.Extension;
That code will work fine, using the FileInfo
class.
Simply add
using System.IO;
However, note that the \
must be escaped as \\
.
Instead, you should use an @""
string, like this:
String file = @"\\mserver-80\docs\somedoc.doc"
In C# the string should be
String file="\\\\mserver-80\\docs\\somedoc.doc";
You can also escacpe the string using the @ character, which is a better alternative:
String file=@"\\mserver-80\docs\somedoc.doc";
other than that the code should work.