簡體   English   中英

我收到一條錯誤消息,顯示“不支持給定路徑的格式”。 嘗試將音頻文件上傳到 sharepoint

[英]I am getting an error that reads “The given path's format is not supported.” when trying to upload audio file to sharepoint

我可以使用下面的代碼行上傳其他文件類型以共享點。 但是,當我嘗試上傳 uadio 文件時,在嘗試創建目錄並將文件保存在 SharePoint 的行上出現錯誤,顯示“不支持給定路徑的格式”。 該行讀取System.IO.Directory.CreateDirectory(pathString);

我懷疑我下面路徑中的反斜杠是個問題

小路

public static string CMSdocs1drive = "\\\\myserver.sharepoint.com@SSL\\DavWWWRoot\\personal\\myname_myorganisation_org_com\\";

代碼上傳並保存到 SharePoint

    protected void btnUpload_Click(object sender, EventArgs e)
 {
            if (FileUpload_Section55_6.HasFile)
                {

                    if (ddlDocument.SelectedIndex == 0)
                    {
                        Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('" + "Upload status: Please select the document type." + "');", true);

                    }
                    else
                    {
                        try
                        {

                            if (FileUpload_Section55_6.PostedFile.ContentLength < 2014572800)
                            {
                                {


                                    if (ddlFilingType.SelectedIndex != 0)
                                    {
                                        if (!String.IsNullOrEmpty(lblCaseID0.Text) && ddlDocument.SelectedValue.ToString() == "203")
                                            pathString = CMSProperties.CMSdocs1drive + "\\" + lblCaseID0.Text + "\\" + ddlFilingType.SelectedItem.Text + "\\" + ".Mp3";
                                    }

                                    if (!Directory.Exists(pathString))
                                    {

                                        System.IO.Directory.CreateDirectory(pathString);
                                        // System.IO.Directory.Move(pathString);

                                    }
                                    if (pathString != controller.CheckIfFilePathExist(pathString))
                                    {

                                        controller.UploadFile(pathString, lblCaseID.Text);
                                    }
                                }
                            }
                            else
                            {
                                Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('" + "Upload status: The file is to big!" + "');", true);
                            }
                            ddlDocument.SelectedIndex = 0;
                        }
                        catch (Exception ex)
                        {
                            ex.Message.ToString();
                            Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('" + "Upload status: The file could not be uploaded. The following error occured:" + "');" + ex, true);
                            Console.WriteLine();
                        }


                    }

                }
                else
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('" + "Upload status: Please select file  " + "');", true);
                }
        }

我懷疑我下面路徑中的反斜杠是個問題

考慮對路徑使用逐字運算符 (@)來表示它包含應忽略的轉義序列字符( \符號)。

 public static string CMSdocs1drive = "\\\\myserver.sharepoint.com@SSL\\DavWWWRoot\\personal\\myname_myorganisation_org_com\\";

使用逐字運算符,您可以避免使用額外的轉義序列字符,例如:

     public static string CMSdocs1drive = @"\\myserver.sharepoint.com@SSL\DavWWWRoot\personal\myname_myorganisation_org_com\";

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM