Ich versuche, eine Datei mit DevExpress speichern als Funktion zum Hochladen, die genau das gleiches wie der Standard asp.net Uploader funktioniert, aber ich bin immer die folgenden Fehlerhochgeladene Datei nicht in dem Verzeichnis gespeichert wird
kann keine finden Teil des Pfades 'C: \ Projekte \ fhs \ fhs \ Uploads \ Dokumente \ VX00150 \ Barry Allen \ Aperture - Signaturvorlage.docx'.
UploadDirectory bezieht sich auf einen virtuellen Verzeichnis-Setup in dem Web-Config, die über die Eigenschaft im bekommen.
string UploadDirectory = WebConfigurationManager.AppSettings["uploadDirectory"].ToString();
der das Verzeichnis
<add key="uploadDirectory" value="~\Uploads\" />
Aber für das Leben von mir enthält Ich kann nicht sehen, warum die Datei auf den Server nicht
protected void UploadControl_FileUploadComplete(object sender, FileUploadCompleteEventArgs e)
{
UploadControl.Enabled = false;
string id = Request.QueryString["Case"];
if (id != null)
{
CaseId = Guid.Parse(id);
OpenCase = _dal.GetCaseById(Guid.Parse(id));
}
string PersonId = Session["CurrentPersonalMainID"].ToString();
Personal = _dal.GetPersonalByPersonalId(new Guid(PersonId));
e.CallbackData = SavePostedFile(e.UploadedFile, OpenCase.CaseReference, Personal.firstName, Personal.lastName);
}
Spar
Die unten gespeichert PostedFile aus aufgerufen werden über
public string SavePostedFile(UploadedFile uploadedFile,string IVACaseRef, string firstName ,string lastName)
{
try
{
if (!uploadedFile.IsValid)
return string.Empty;
string fileName = uploadedFile.FileName;
FileInfo fileInfo = new FileInfo(uploadedFile.FileName);
string fullFileName = CombinePath(fileName);
string docsPath = UploadDirectory + @"documents\" + IVACaseRef + @"\" + firstName + " " +
lastName + @"\";
string resFileName =docsPath + fileInfo.Name;
bool exists = System.IO.Directory.Exists(resFileName);
if (!exists)
System.IO.Directory.CreateDirectory(docsPath);
uploadedFile.SaveAs(Server.MapPath(resFileName), true);
System.Net.Mail.Attachment attachment;
attachment = new System.Net.Mail.Attachment(resFileName.ToString());
// we need to reget this as issue with postback and the fileuplaod
FormsIdentity _identity = (FormsIdentity)Context.User.Identity;
_identity = (FormsIdentity)Context.User.Identity;
return fileName;
}
catch (Exception ex)
{
string inner = string.Empty;
if (ex.InnerException != null)
{
inner = ex.InnerException.ToString();
}
// logger.Error("Error in GetNotificationById function aperturenetdal " + ex.ToString() + " " + inner);
return "";
Vielleicht ist es deshalb: '\ fhs \ fhs' – Hackerman
@Hackerman nein ist es nicht, dass das Verzeichnis so ist, dass ich Angst habe –