filepath
variable is coming over UDP socket. And after my codes are below:
string filename=null;
string filetype=null;
if (File.Exists(filepath)){
filename=?????;
filetype=????;
}
Can I access file name and file type?
filepath
variable is coming over UDP socket. And after my codes are below:
string filename=null;
string filetype=null;
if (File.Exists(filepath)){
filename=?????;
filetype=????;
}
Can I access file name and file type?
var f = new FileInfo(filepath);
filename = f.Name;
filetype = f.Extension;
string filename = null;
string filetype = null;
if (File.Exists(filepath)) {
filename = Path.GetFileName(path);
filetype = Path.GetExtension(path);
}
You can get the filename and filetype using Path class.
filename = Path.GetFileNameWithoutExtension(filepath)
filetype = Path.GetExtension(filepath)