更新时间:2022-03-08 19:58:46
我尝试了一些代码来让您使用文件名获取文件扩展名
Hi,
I tried some code for you to get file extension by using filename
DirectoryInfo dinfo = new DirectoryInfo(Server.MapPath("~/Images"));
FileInfo[] finfo = dinfo.GetFiles("winter.*");
int l=finfo.Length;
string ext=Path.GetExtension(finfo[0].FullName);
在这里,您必须传递文件名而不是"winter"
然后将文件信息存储在finfo数组中.
这样我们就可以得到该文件扩展名
我希望你能理解我说的话
***的
Here you''ve to pass your file name instead of "winter"
Then The file information stored in finfo array.
So we can get that file extension
I hope you understood What I said
All the Best
您的文件名"... \ Images \ 34"没有扩展名.
Your file name "...\Images\34" has no extension.
要获取文件扩展名,
To get File Extension,
Response.Write(Path.GetExtension(@"F:\Articles\ValidationControls\ValidationControls.zip"));
请参阅下面的链接
^ ]
Refer below link
http://codes.codedigest.com/CodeDigest/68-Get-File-Extension--File-Name--File-Name-without-Extension-from-Path-in-C--and-ASP-Net.aspx[^]