בעית גישה בהעתקת קובץ לשרת - תכנות - HWzone פורומים
עבור לתוכן
  • צור חשבון

בעית גישה בהעתקת קובץ לשרת


פיני1805

Recommended Posts

שלום,

אני בונה אתר ב - ASP.NET ויש לי בעית גישת בהעלאת קובץ לשרת. ברגע שהלקוח מנסה לעלות את הקובץ לשרת אז התוכנית

נופלת בגלל בעית גישה. מצורפת תמונה לחריגה. צרפתי גם את הקוד. עזרתם תודה.



protected void B_upload_Click(object sender, EventArgs e)

{

if (myFile.PostedFile != null)

{

// File was sent

// Get a reference to PostedFile object

HttpPostedFile upFile = myFile.PostedFile;

// Get size of uploaded file

int nFileLen = upFile.ContentLength;

// Allocate a buffer for reading of the file

byte[] myData = new byte[nFileLen];

// Read uploaded file from the Stream

upFile.InputStream.Read(myData, 0, nFileLen);

WriteToFile("C:/", ref myData);

}

else

{

// No file

}

}

protected void WriteToFile(string strPath, ref byte[] Buffer)

{

// Create a file

FileStream newFile = new FileStream(strPath, FileMode.Create);

// Write data to the file

newFile.Write(Buffer, 0, Buffer.Length);

// Close file

newFile.Close();

}

קישור לתוכן
שתף באתרים אחרים

ארכיון

דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.

×
  • צור חדש...