2010-11-23 35 views
1

我需要創建一個名爲log的文件夾,然後在D:\New Folder之類的文本框中給出路徑,而不會在var _logFolderPath = @"D:\New Folder\log"; 之類的代碼中提供硬核路徑,之後我需要創建兩個文本文件ba.txt和ra.txt在日誌文件夾在代碼中創建文件夾而不提供核心路徑

這是我的代碼

DirectoryInfo Folder = new DirectoryInfo(textboxPath.Text); 
var _logFolderPath =textboxPath.Text; 
if (Folder.Exists) 
if (!Directory.Exists(_logFolderPath)) Directory.CreateDirectory(_logFolderPath); 

using (var dest = File.CreateText(Path.Combine(_logFolderPath, line2 + ".txt"))) 

參考 comparing two text files

+2

有什麼問題? – 2010-11-23 12:39:01

回答

4

如何改變2號線到:

var _logFolderPath = Path.Combine(textboxPath.Text.Trim(), "log"); 
相關問題