Şu anda uygulamamla ilgili bir sorun yaşıyorum ve bunun yalnızca benim mantığım olduğunu düşünmeye başladım. Bu formlara ve MSDN'e göz attıktan sonra bile anlayamıyorum.StreamWriter proje dizini ve alt dizini?
Uygulama dizinimde bir metin belgesi oluşturmak ve bu belgeyi içeren bir alt klasör oluşturmak için StreamWriter kullanmaya çalışıyorum. Şu anda sadece benim apps exe dizininde dosya damping tutar.
string runTimeDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
string recipeDirectory = Path.Combine(runTimeDirectory, "Recipes");
if (!Directory.Exists(recipeDirectory))
{
//Recipes directory doesnt exist so create it
Directory.CreateDirectory(recipeDirectory);
}
// Write text to file
using (StreamWriter OutputFile = new StreamWriter(recipeDirectory + RecipeName + @".txt"))
{
sadece bir tahmin, ama 'recipeDirectory' muhtemelen bir '\' ile bitmiyor, bu yüzden ile sonuçlanırsiniz: 'C: \ foo \ Recpiesmyrecipe.txt' yerine: C: \ foo \ Recipies \ myrecipie.txt" – CodingGorilla
Bu doğru, yaratılıyor dosya + dosya dizini adı.Aşağıdaki cevabı görüyorum: –