473,387 Members | 1,548 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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?
Feb 28 '10 #1

✓ answered by tlhintoq

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

Expand|Select|Wrap|Line Numbers
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Windows;
  5. using System.Windows.Controls;
  6. using System.Windows.Data;
  7. using System.Windows.Documents;
  8. using System.Windows.Forms;
  9. using System.Windows.Input;
  10. using System.Windows.Media;
  11. using System.Windows.Media.Imaging;
  12. using System.Windows.Navigation;
  13. using System.Windows.Shapes;
  14. using MessageBox=System.Windows.Forms.MessageBox;
  15.  
  16. namespace WpfApplication1
  17. {
  18.     /// <summary>
  19.     /// Interaction logic for Window1.xaml
  20.     /// </summary>
  21.     public partial class Window1 : Window
  22.     {
  23.         public Window1()
  24.         {
  25.             InitializeComponent();
  26.             System.Windows.Forms.FolderBrowserDialog bob = new FolderBrowserDialog();
  27.             bob.ShowDialog();
  28.             string BobsPath = bob.SelectedPath;
  29.             MessageBox.Show(BobsPath, "User Selected");
  30.         }
  31.     }
  32. }
  33.  

6 9610
tlhintoq
3,525 Expert 2GB
User needs to provide a folder name.
Could anyone give me an idea how to do it?
Use the SaveFileDialog in the toolbox.

http://www.lmgtfy.com/?q=MSDN+SaveFi...UTF-8&oe=UTF-8
Feb 28 '10 #2
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 BrowserFolderDialog but only supported when using the forms. Is there another ways for me to do it?

Thank.
Mar 1 '10 #3
tlhintoq
3,525 Expert 2GB
I've never created a WPF application until just now... but it sure seems like it let me make a FolderBrowserDialog.

Expand|Select|Wrap|Line Numbers
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Windows;
  5. using System.Windows.Controls;
  6. using System.Windows.Data;
  7. using System.Windows.Documents;
  8. using System.Windows.Forms;
  9. using System.Windows.Input;
  10. using System.Windows.Media;
  11. using System.Windows.Media.Imaging;
  12. using System.Windows.Navigation;
  13. using System.Windows.Shapes;
  14. using MessageBox=System.Windows.Forms.MessageBox;
  15.  
  16. namespace WpfApplication1
  17. {
  18.     /// <summary>
  19.     /// Interaction logic for Window1.xaml
  20.     /// </summary>
  21.     public partial class Window1 : Window
  22.     {
  23.         public Window1()
  24.         {
  25.             InitializeComponent();
  26.             System.Windows.Forms.FolderBrowserDialog bob = new FolderBrowserDialog();
  27.             bob.ShowDialog();
  28.             string BobsPath = bob.SelectedPath;
  29.             MessageBox.Show(BobsPath, "User Selected");
  30.         }
  31.     }
  32. }
  33.  
Mar 1 '10 #4
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.Create(bob.SelectedPath + @"\\abc.xml"))

=)
Mar 2 '10 #5
tlhintoq
3,525 Expert 2GB
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:\returnedfolder\\abc.xml

instead of
C:\returnedfolder\abc.xml

Where you have an extra (blank) level of folder hiarchy
Mar 2 '10 #6
I got it.
Thank you! =)
Mar 3 '10 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Stanav | last post by:
Hello all, Thanks in advance for any replies... Now, my question is: Is it possible to do a multiple files download for a single response event on an aspx page? If there is, please give me some...
0
by: Xah Lee | last post by:
Interactive Find and Replace String Patterns on Multiple Files Xah Lee, 2006-06 Suppose you need to do find and replace of a string pattern, for all files in a directory. However, you do not...
5
by: cybersangeeth | last post by:
Hi, I need to read 1KB each time from multiple files in a folder and pass it to a byte array in a struct to be sent through a socket. I'm a C++ newbie. I managed to read 1KB each time from one...
2
by: rengask | last post by:
I got the code to find and replace within an open text file. ------------------ Private Sub cmdFile_Click() Dim strTemp As String txtFile = "" dlg.FileName = "*.*" dlg.ShowOpen ...
3
by: =?Utf-8?B?R3VpZG8gS3JhdXM=?= | last post by:
Hi, my application writes some log files. It runs on notebooks and PCs. Several different users may log on to the machines. Which is the right place to store the log files? Should I create...
1
by: koraykazgan | last post by:
Hi all, I have to solve the following scenario. On my webpage, the user is able to view some text content. I have to put a "Save Document" button on that page. If the user wants to save that...
10
by: kimiraikkonen | last post by:
Hi, I have an app which has a listbox and when i double click an associated fileS, i want their paths to be added into listbox in my application. This code works good when i try to open a...
1
by: coolheadash | last post by:
Hi all, I have a folder named "folder" having multiple files inside different nested folders. Many files under it have a certain text that i am looking for. Before this line, I have to add a line...
3
by: sscpord | last post by:
I am new to python and still learning but I have a problem that I think should be able to be solved using a python script. I have a main folder on my desktop called “CREATED” and within this folder...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.