OpenFileDialog dlg = new OpenFileDialog();
dlg.Filter = Filter;
dlg.Multiselect = Multiselect;
if ((bool)dlg.ShowDialog())
{
foreach (FileInfo file in dlg.Files)
源代码使用选择框获得文件信息 ,现在我有文件的路径请问该怎样获得文件信息呢?FileInfo file in dlg.Files 该如何替代来声明
FileInfo file = new FileInfo("文件路径");
这样写就会报错:
错误:unhandled error in silverlight 2 application 试图访问该方法时失败:system.io.fileinfo..ctor(system.string) 位于
dc.fileupload.fileuploadcontrol..ctor()
位于fileupload.app.application_startup(object sender,startupeventargs e)
位于 system.windows.coreinvokehandler.invokeeventhandler(int32 typeindex,delegate handlerdelegate,object sender,object args)
位于 ms.internal.jolthelper.fireevent(intptr unmanagedobj,intptr unmanagedobjargs,int32 argstypeindex,string eventname)
dlg.FileNames是个选中文件名的数组,直接循环操作就好了啊
foreach (string fileName in dlg.FileNames)
{
FileInfo file = new FileInfo(fileName);
//通过file实例就能取得文件相关信息了
//或者用File类的静态方法获取文件相关信息
}