, dataLen);
SPSite sps = SPControl.GetContextSite(Context);
sps.AllowUnsafeUpdates = true;
SPWeb spw = sps.OpenWeb();
spw.AllowUnsafeUpdates = true;
SPList list = spw.Lists["TestDocs"];
SPFolder folder = list.RootFolder;
bool ex = false;
Response.Write("folder.Exists:" + folder.Exists + "<br/>");
//获取不带路径的纯文件名
filename = FileUpload1.FileName;
if (folder.Exists)
{
try
{
ex = folder.Files[filename].Exists;
Response.Write("已有同名文件。");
return;
}
catch
{
folder.Files.Add(filename, fileData, true);
}
}
}
SPSite sps = SPControl.GetContextSite(Context);
sps.AllowUnsafeUpdates = true;
SPWeb spw = sps.OpenWeb();
spw.AllowUnsafeUpdates = true;
SPList list = spw.Lists["TestDocs"];
SPFolder folder = list.RootFolder;
bool ex = false;
Response.Write("folder.Exists:" + folder.Exists + "<br/>");
//获取不带路径的纯文件名
filename = FileUpload1.FileName;
if (folder.Exists)
{
try
{
ex = folder.Files[filename].Exists;
Response.Write("已有同名文件。");
return;
}
catch
{
folder.Files.Add(filename, fileData, true);
}
}
}