0

私は現在、電子メールをオンラインの共有ポイントに保存する Outlook アドインを開発していますが、それらを保存する前に、同じ名前のファイルが既に存在するかどうかを確認して、何も上書きしないようにする必要があります。ファイル:

            {
            currExplorer = OutlookApp.ActiveExplorer();
            selection = currExplorer.Selection;
            if (selection != null)
            {
                SharePointHelper spHelper = new SharePointHelper("LoginName", "Password", "Url/FolderDirectory");
                if (selection.Count > 0)
                {
                    for (int i = 1; i <= selection.Count; i++)
                    {
                        var item = selection[i] as Outlook.MailItem;
                        if (item == null) 
                            continue;

                        // Check for attachments and save
                        currMail = item;

                        string fileName = String.Format("{0} - {1}.msg", SafeFileName(currMail.SenderName), SafeFileName(currMail.Subject));
                        string filePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), fileName);
                        currMail.SaveAs(filePath, Outlook.OlSaveAsType.olMSG);

                        System.Net.HttpStatusCode status = spHelper.UploadFile(filePath, fileName); 
                        if (status != System.Net.HttpStatusCode.Created)
                            MessageBox.Show(fileName + " failed to upload.");
                    }
                }
            }
        }

私は初心者なので、これを行う方法についての経験が不足しています。あなたの助けに心から感謝します。

4

3 に答える 3

0

使用するSystem.IO.File.Exists(string path)

于 2013-04-11T11:15:00.643 に答える
0

SharePoint ファイルに対してチェックしたい場合はMicrosoft.SharePoint.Client.Web、メソッドGetFileByServerRelativeUrl(string serverRelativeUrl) GetFileByServerRelativeUrlを使用して調べることができます。

asp.net でクライアント オブジェクト モデルを使用して sharepoint ライブラリから sharepoint Excel ファイルを取得する

ファイルをライブラリからオブジェクトにロードすると、!= nullチェックを実行でき、ファイルが null でない場合は、ファイルの名前を変更できます。

于 2013-04-09T16:54:53.720 に答える