using System;
using System.Web;
using System.Web.UI;
using System.IO;
namespace webdb.classes
{
///
/// UploadFile 的摘要说明。
///
public class UploadFile
{
public UploadFile()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
///
/// 无参数的上传文件
///
///
public string GetSqlFile()
{
string sqlfile="";
string path = HttpContext.Current.Request.PhysicalApplicationPath.ToString()+"/upload";
if(Directory.Exists(path))
{
}
else
{
Directory.CreateDirectory(path);
}
HttpFileCollection files = HttpContext.Current.Request.Files;
if(files[0].FileName.ToString().Length>0)
{
string filename = files[0].FileName.ToString();
string datestr = DateTime.Now.ToString("yyyyMMddHmmss")+DateTime.Now.Millisecond;
string ext = filename.Substring(filename.LastIndexOf("."));
files[0].SaveAs(path+"\\"+datestr+ext);
sqlfile=datestr+ext;
}
else
{
}
return sqlfile;
}
public string GetSqlFile(string dir)
{
string sqlfile="";
string path = HttpContext.Current.Request.PhysicalApplicationPath.ToString()+"/upload/";
path +="\\"+dir;
if(Directory.Exists(path))
{
}
else
{
Directory.CreateDirectory(path);
}
HttpFileCollection files = HttpContext.Current.Request.Files;
if(files[0].FileName.ToString().Length>0)
{
string filename = files[0].FileName.ToString();
string datestr = DateTime.Now.ToString("yyyyMMddHmmss")+DateTime.Now.Millisecond;
string ext = filename.Substring(filename.LastIndexOf("."));
files[0].SaveAs(path+"/"+datestr+ext);
sqlfile=datestr+ext;
}
else
{
}
return sqlfile;
}
}
}