ファイルをデータベースに保存するときに/~/文字を削除する方法に問題があります。問題は、ファイルアップロードコントローラーにファイルがない場合です。NavigateUrlフォームのaspハイパーリンクをグレープし、savePathに追加して保存しますが、例外が発生します'ディレクトリが見つからない
パス 'C:\inetpub\wwwroot\ideaPark\DesktopModules\ResourceModule\pdf_resources\~\DesktopModules\ResourceModule\pdf_resources\New Text Document.txt' の一部が見つかりませんでした。
//save pdf docs
String savePathPDF_Resouce = @"~/DesktopModules/ResourceModule/pdf_resources/";
String savePathPDF_Vocab = @"~/DesktopModules/ResourceModule/pdf_resources/";
if (fuPDFDoc.HasFile || fupdfVocabularyURL.HasFile)
{
String fileName = fuPDFDoc.FileName;
String fileName_Vocab = fupdfVocabularyURL.FileName;
savePathPDF_Resouce += fileName;
savePathPDF_Vocab += fileName_Vocab;
fuPDFDoc.SaveAs(Server.MapPath(savePathPDF_Resouce));
fupdfVocabularyURL.SaveAs(Server.MapPath(savePathPDF_Vocab));
}
else
if (!fuPDFDoc.HasFile || !fupdfVocabularyURL.HasFile)
{
savePathPDF_Resouce += hl_doc_res.NavigateUrl.ToString();
savePathPDF_Vocab += hl_doc_vocab.NavigateUrl.ToString();
fuPDFDoc.SaveAs(Server.MapPath(savePathPDF_Resouce));
fupdfVocabularyURL.SaveAs(Server.MapPath(savePathPDF_Vocab));
}