C
C#4mo ago
MerryToad

Not writing, but not returning errors

private void button1_Click(object sender, EventArgs e)
{
try
{

string baseDir = AppDomain.CurrentDomain.BaseDirectory;

string currentDirectory = Directory.GetCurrentDirectory();
string filePath = Path.Combine(currentDirectory, "Dialog.txt");
MessageBox.Show(filePath);


using (StreamWriter writer = new StreamWriter(filePath))
{
writer.Write("Yes");
}

}
catch (Exception ex)
{
MessageBox.Show($"{ex}");
}

this.Close();
}
private void button1_Click(object sender, EventArgs e)
{
try
{

string baseDir = AppDomain.CurrentDomain.BaseDirectory;

string currentDirectory = Directory.GetCurrentDirectory();
string filePath = Path.Combine(currentDirectory, "Dialog.txt");
MessageBox.Show(filePath);


using (StreamWriter writer = new StreamWriter(filePath))
{
writer.Write("Yes");
}

}
catch (Exception ex)
{
MessageBox.Show($"{ex}");
}

this.Close();
}
The directory that VS gives when I copy the path: C:\Users\Confidential\source\repos\Toad Editor\Toad Editor\File Selector\Dialog.txt The directory this gives me: C:\Users\Confidential\source\repos\Toad Editor\Toad Editor\bin\Debug\net8.0-windows\Dialog.txt
5 Replies
MerryToad
MerryToadOP4mo ago
The path File Explorer gives me: "C:\Users\Confidential\source\repos\Toad Editor\Toad Editor\bin\Debug\net8.0-windows\Dialog.txt" So it seems that it's getting the curect directory, but the issue is writing to the file Interestingly, searching for the path vs gives in file explorer and copying the dialog.txt path gives me this... "C:\Users\Confidential\source\repos\Toad Editor\Toad Editor\File Selector\Dialog.txt" I'm so ungodly confused
ACiDCA7
ACiDCA74mo ago
what exactly is the issue? have you checked the file in the location of your messagebox?
MerryToad
MerryToadOP4mo ago
That's what I did here The issue is that it's not writing to the file nor is it giving an error
ACiDCA7
ACiDCA74mo ago
use the debugger to step through the code
ChaChaCha
ChaChaCha4mo ago
does writer.write return any values
Want results from more Discord servers?
Add your server