C
C#2y ago
Pixel

❔ File.WriteAllText(string, string?) and similar fail to write to file

Hi, im working on a Logger library and im trying different ways to implement logging to a file, but no matter what i tried (File.WriteAllText, File.WriteAllTextAsync, File.Append, FileStream.Write) they all end creating a file, but not writing to it the function for writing text to a file is as follow
private void File_WriteText(string ToPrint)
{
File.WriteAllText(LogFile, ToPrint);
}
private void File_WriteText(string ToPrint)
{
File.WriteAllText(LogFile, ToPrint);
}
LogFile and File_WriteText are both members of the OLog class, LogFile is a public string containing a path to the log file, by default it is log, if i missed any information do ask for more, the end result will most likely be open source anyways OS:: Arch Linux .NET:: 7.0/6.0 (both have the same issue)
18 Replies
phaseshift
phaseshift2y ago
You're probably looking in the wrong place for the file. There's very little that can go wrong with WriteAllText
ffmpeg -i me -f null -
eventually you can use sysinternal's tool to look where your program is writing but seems overkill for this
Pixel
Pixel2y ago
i can see the file get created it just does not have any content
Angius
Angius2y ago
Run the debugger to ensure the string you're trying to write actually contains something?
Pixel
Pixel2y ago
yeah it contains something
ffmpeg -i me -f null -
is there an exception being annihilated?
Pixel
Pixel2y ago
how would i check?
sibber
sibber2y ago
what tool is that?
ffmpeg -i me -f null -
filemon, which has been replaced by process monitor
sibber
sibber2y ago
good to know this exists thanks
ffmpeg -i me -f null -
only on windows tho'
sibber
sibber2y ago
yeah ik
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Pixel
Pixel2y ago
damnit shit's not solved
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Pixel
Pixel2y ago
ffs it's not solved
ffmpeg -i me -f null -
how writing a file on a local drive can take so much to debug
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.