日期:2014-05-16 浏览次数:21007 次
public bool uploadfile(string netLocation, string localPath, ref string retString)
{
bool retState = false;
string tmp = "http://" + serverIP + "/" + netLocation;
try
{
WebClient myWebClient = new WebClient();
FileStream fs = new FileStream(localPath, FileMode.Open, FileAccess.Read);
BinaryReader br = new BinaryReader(fs);
Byte[] postArray = br.ReadBytes(Convert.ToInt32(fs.Length));
Stream postStream = myWebClient.OpenWrite(tmp.Trim(), "PUT");
if (postStream.CanWrite)
{
postStream.Write(postArray, 0, postArray.Length);
} postStream.Close();
fs.Close();
retString = "上传成功";
retState = true;
}
catch (Exception ex)
{
retState = false;
retString = tmp.Trim() + ":" + ex.Message;
}
return retState;
}
LoadModule dav_module modules/mod_dav.so
LoadModule dav_fs_module modules/mod_dav_fs.so