1

How to save a file that is not to replace the previous file on windows phone 8.1? Because using the code below, there is always a message dialog to replace and cancel, can not change the file name.

This is the code:

public void Save()
        {
            //isContentChanged = false;
            FileSavePicker savePicker = new FileSavePicker();
            savePicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary; 
            //{
            //    SuggestedStartLocation = PickerLocationId.PicturesLibrary
            //};
            savePicker.FileTypeChoices.Add("Word Document", new List<string>() { ".docx" });
            savePicker.FileTypeChoices.Add("Word 97 - 2003 Document", new List<string>() { ".doc" });
            savePicker.FileTypeChoices.Add("Rich Text Document", new List<string>() { ".rtf" });
            savePicker.DefaultFileExtension = ".docx";
            savePicker.SuggestedFileName = "WordDocument";
            savePicker.PickSaveFileAndContinue();

        }

        /// <summary>
        /// Continues the file save picker.
        /// </summary>
        /// <param name="fileSavePickerContinuationEventArgs">The <see cref="FileSavePickerContinuationEventArgs"/> instance containing the event data.</param>
        public async void ContinueFileSavePicker(FileSavePickerContinuationEventArgs args)
        {
            bool showErrorMsg = false;
            if (args.File != null)
            {
                try
                {
                    System.Threading.CancellationTokenSource src = new System.Threading.CancellationTokenSource();
                    Debug.WriteLine(args.File.Name + " was saved.");
                    richTextBox.Save(args.File);
                }
                catch
                {
                    showErrorMsg = true;
                }
                if (showErrorMsg)
                {
                    MessageDialog dialog = new MessageDialog("Save Failed");
                    await dialog.ShowAsync();
                }
            }
        }

Please help me

Rose
  • 613
  • 4
  • 22

0 Answers0