获取上传的文件扩展名 [英] Get the uploaded File Extension
本文介绍了获取上传的文件扩展名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个.txt文件,我已将此文件的文件扩展名更改为.exe。
现在我想获取文件扩展名.txt。
怎么可能。我使用下面的代码
string extension = System.IO.Path.GetExtension(fud.PostedFile.FileName);
我得到扩展名.exe但我需要.txt。
I have a .txt file and i have changed the file extension of this file to .exe.
Now i want to get the file extension .txt.
How is it possible. I have used below code
string extension = System.IO.Path.GetExtension(fud.PostedFile.FileName);
I am getting extension .exe but i need .txt.
推荐答案
string myFilePath = @"C:\MyFile.txt";
string ext = Path.GetExtension(myFilePath);
使用System.IO命名空间
use System.IO namespace
嗨
通过这个 -
find-out-the-real-file-type [ ^ ]
这篇关于获取上传的文件扩展名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文