清除服务器中的文件 [英] clear the files in server

查看:126
本文介绍了清除服务器中的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是使用文件上传控件将excel文件上传到网格视图.但是excel文件保存在解决方案目录中.因此,每次我添加任何excel文件时,它们都会被添加到目录中.我应该如何清除所有>

我用了这段代码

iam uploading an excel file using an file upload control to a grid view.but the excel file is saving in the solution directory. so every time i add any excel files they are getting added to the directory . how should i clear all>

i used this code

path = Server.MapPath("~/");
                String sConnectionString = "";
                filebrowse.SaveAs(Server.MapPath("~/") + System.IO.Path.GetFileName(filebrowse.FileName));






请咨询...






please advice...

推荐答案

hi
肯定会将文件上传到根目录.您需要在应用程序根目录上创建一个UploadedFiles 之类的文件夹,并使用以下代码:
hi
definitely it will upload the file to the root directory. you need to create a Folder like UploadedFiles on your application root and use the following code:
filebrowse.SaveAs(Server.MapPath("UploadedFiles") +"\\"+ System.IO.Path.GetFileName(filebrowse.FileName));


这篇关于清除服务器中的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆