Save multiple files within a folder

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Janice Hui
    New Member
    • Feb 2010
    • 16

    Save multiple files within a folder

    I want to create a save function which allows the user to save all files within a folder.
    User needs to provide a folder name.
    Could anyone give me an idea how to do it?
  • tlhintoq
    Recognized Expert Specialist
    • Mar 2008
    • 3532

    #2
    User needs to provide a folder name.
    Could anyone give me an idea how to do it?
    Use the SaveFileDialog in the toolbox.

    For all those people who find it more convenient to bother you with their question rather than to Google it for themselves.

    Comment

    • Janice Hui
      New Member
      • Feb 2010
      • 16

      #3
      Hi tlhintoq,

      Thank for you reply.

      However, what i needed is the system will prompt a browser folder window that allows the user to enter the folder name. Then, the system will automatically save two files within created folder. I am using wpf and C#, currently i found the way to do it by using the BrowserFolderDi alog but only supported when using the forms. Is there another ways for me to do it?

      Thank.

      Comment

      • tlhintoq
        Recognized Expert Specialist
        • Mar 2008
        • 3532

        #4
        I've never created a WPF application until just now... but it sure seems like it let me make a FolderBrowserDi alog.

        Code:
        using System;
        using System.Collections.Generic;
        using System.Text;
        using System.Windows;
        using System.Windows.Controls;
        using System.Windows.Data;
        using System.Windows.Documents;
        using System.Windows.Forms;
        using System.Windows.Input;
        using System.Windows.Media;
        using System.Windows.Media.Imaging;
        using System.Windows.Navigation;
        using System.Windows.Shapes;
        using MessageBox=System.Windows.Forms.MessageBox;
        
        namespace WpfApplication1
        {
            /// <summary>
            /// Interaction logic for Window1.xaml
            /// </summary>
            public partial class Window1 : Window
            {
                public Window1()
                {
                    InitializeComponent();
                    System.Windows.Forms.FolderBrowserDialog bob = new FolderBrowserDialog();
                    bob.ShowDialog();
                    string BobsPath = bob.SelectedPath;
                    MessageBox.Show(BobsPath, "User Selected");
                }
            }
        }

        Comment

        • Janice Hui
          New Member
          • Feb 2010
          • 16

          #5
          Hi tlhintoq,

          Thank a lot for your guide.

          Based on your explanation, i already get what i need.
          And, in order for me to save the file to the particular folder, i add the following code.

          using (XmlReader reader = XmlReader.Creat e(bob.SelectedP ath + @"\\abc.xml" ))

          =)

          Comment

          • tlhintoq
            Recognized Expert Specialist
            • Mar 2008
            • 3532

            #6
            If you are using the @ in front of your string, you shouldn't need to use a double \\

            In fact that should be making your path

            C:\returnedfold er\\abc.xml

            instead of
            C:\returnedfold er\abc.xml

            Where you have an extra (blank) level of folder hiarchy

            Comment

            • Janice Hui
              New Member
              • Feb 2010
              • 16

              #7
              I got it.
              Thank you! =)

              Comment

              Working...