[FONT=細明體]Chào diễn đàn
Mình đã viết đoạn mã sau: copy nhung file từ thu mực cố định đến thư mục chỉ định bằng hàm folderbrowserdialog, nhưng bây giờ mình muốn dùng lênh open để mở thư mục đó lên, tuy nhiên
mình không biết làm thế nào để nhớ path đã chọn trên. Hoặc mình muốn sử dung path trên để làm những thao tác tiếp theo
Thanks in advance
Mã code như sau:
public[FONT=細明體] [/FONT][FONT=細明體]partial[/FONT][FONT=細明體] [/FONT][FONT=細明體]class[/FONT][FONT=細明體] [/FONT][FONT=細明體]Form1[/FONT][FONT=細明體] : [/FONT][FONT=細明體]Form[/FONT]
[/FONT]
[FONT=細明體] {[/FONT]
[FONT=細明體] string sourcePath = @"C:\text\";[/FONT]
[FONT=細明體] string fileName1 = @"text1.xml";[/FONT]
[FONT=細明體] string fileName2 = @"text2.xml";[/FONT]
[FONT=細明體] [FONT=細明體] [/FONT][/FONT]
[FONT=細明體] public Form1()[/FONT]
[FONT=細明體] {[/FONT]
[FONT=細明體] InitializeComponent();[/FONT]
[FONT=細明體] }[/FONT]
[FONT=細明體] private void btnfolder_Click(object sender, EventArgs e)[/FONT]
[FONT=細明體] {[/FONT]
[FONT=細明體] [FONT=細明體] [/FONT][FONT=細明體]DialogResult[/FONT][FONT=細明體] folder = folderBrowserDialog1.ShowDialog();[/FONT][/FONT]
[FONT=細明體] if (folder == DialogResult.OK)[/FONT]
[FONT=細明體] {[/FONT]
[FONT=細明體] var destinationFolderName = folderBrowserDialog1.SelectedPath;[/FONT]
[FONT=細明體] if (Directory.Exists(destinationFolderName))[/FONT]
[FONT=細明體] {[/FONT]
[FONT=細明體] [FONT=細明體] [/FONT][FONT=細明體]File[/FONT][FONT=細明體].Copy(sourcePath + [/FONT][FONT=細明體]"/"[/FONT][FONT=細明體] + fileName1, destinationFolderName[/FONT][/FONT]
[FONT=細明體] + "/" + fileName1);[/FONT]
[FONT=細明體] File.Copy(sourcePath + "/" + fileName2, destinationFolderName[/FONT]
[FONT=細明體] + "/" + fileName2);[/FONT]
[FONT=細明體] }[/FONT]
[FONT=細明體] private[FONT=細明體] void btnopen_Click(object sender, EventArgs e)
??? Mình muốn viết đoạn chương trình nhớ path từ lệnh trước???
Open tất cả thư mục nói trên
VD: path nhận được là D:\folder\A và mình muốn nhớ luôn path này, đến khi mình dùng lệnh folderbrowserdialog chọn thư mục mới thì sẽ thay đổi
[/FONT][/FONT]
[FONT=細明體] {[/FONT]
Mình đã viết đoạn mã sau: copy nhung file từ thu mực cố định đến thư mục chỉ định bằng hàm folderbrowserdialog, nhưng bây giờ mình muốn dùng lênh open để mở thư mục đó lên, tuy nhiên
mình không biết làm thế nào để nhớ path đã chọn trên. Hoặc mình muốn sử dung path trên để làm những thao tác tiếp theo
Thanks in advance
Mã code như sau:
public[FONT=細明體] [/FONT][FONT=細明體]partial[/FONT][FONT=細明體] [/FONT][FONT=細明體]class[/FONT][FONT=細明體] [/FONT][FONT=細明體]Form1[/FONT][FONT=細明體] : [/FONT][FONT=細明體]Form[/FONT]
[/FONT]
[FONT=細明體] {[/FONT]
[FONT=細明體] string sourcePath = @"C:\text\";[/FONT]
[FONT=細明體] string fileName1 = @"text1.xml";[/FONT]
[FONT=細明體] string fileName2 = @"text2.xml";[/FONT]
[FONT=細明體] [FONT=細明體] [/FONT][/FONT]
[FONT=細明體] public Form1()[/FONT]
[FONT=細明體] {[/FONT]
[FONT=細明體] InitializeComponent();[/FONT]
[FONT=細明體] }[/FONT]
[FONT=細明體] private void btnfolder_Click(object sender, EventArgs e)[/FONT]
[FONT=細明體] {[/FONT]
[FONT=細明體] [FONT=細明體] [/FONT][FONT=細明體]DialogResult[/FONT][FONT=細明體] folder = folderBrowserDialog1.ShowDialog();[/FONT][/FONT]
[FONT=細明體] if (folder == DialogResult.OK)[/FONT]
[FONT=細明體] {[/FONT]
[FONT=細明體] var destinationFolderName = folderBrowserDialog1.SelectedPath;[/FONT]
[FONT=細明體] if (Directory.Exists(destinationFolderName))[/FONT]
[FONT=細明體] {[/FONT]
[FONT=細明體] [FONT=細明體] [/FONT][FONT=細明體]File[/FONT][FONT=細明體].Copy(sourcePath + [/FONT][FONT=細明體]"/"[/FONT][FONT=細明體] + fileName1, destinationFolderName[/FONT][/FONT]
[FONT=細明體] + "/" + fileName1);[/FONT]
[FONT=細明體] File.Copy(sourcePath + "/" + fileName2, destinationFolderName[/FONT]
[FONT=細明體] + "/" + fileName2);[/FONT]
[FONT=細明體] }[/FONT]
[FONT=細明體] private[FONT=細明體] void btnopen_Click(object sender, EventArgs e)
??? Mình muốn viết đoạn chương trình nhớ path từ lệnh trước???
Open tất cả thư mục nói trên
VD: path nhận được là D:\folder\A và mình muốn nhớ luôn path này, đến khi mình dùng lệnh folderbrowserdialog chọn thư mục mới thì sẽ thay đổi
[/FONT][/FONT]
[FONT=細明體] {[/FONT]