Why on FileStream File.Create i'm getting an exception and it's not creating the directory and the f

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
This is the code :FileStream fs=File.Create(settings);
fs.Close();

settings contain : "C:\Users\bout0_000\AppData\Local\ScreenVideoRecorder\ScreenVideoRecorder\settings\settings.txt"
But instead of creating it im getting an exception on the FileStream line :
The type initializer for ScreenVideoRecorder.Options_DB threw an exception
The full exception :System.TypeInitializationException was unhandled
HResult=-2146233036
Message=The type initializer for ScreenVideoRecorder.Options_DB threw an exception.
Source=ScreenVideoRecorder
TypeName=ScreenVideoRecorder.Options_DB
StackTrace:
at ScreenVideoRecorder.Options_DB.Get_Video_File()
at ScreenVideoRecorder.Form1..ctor() in d:C-SharpScreenVideoRecorderScreenVideoRecorderWorkingVersionForm1.cs:line 54
at ScreenVideoRecorder.Program.Main() in d:C-SharpScreenVideoRecorderScreenVideoRecorderWorkingVersionProgram.cs:line 18
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException: System.IO.DirectoryNotFoundException
HResult=-2147024893
Message=Could not find a part of the path C:Usersbout0_000AppDataLocalScreenVideoRecorderScreenVideoRecordersettingssettings.txt.
Source=mscorlib
StackTrace:
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize)
at System.IO.File.Create(String path)
at DannyGeneral.OptionsFile..ctor(String settings) in d:C-SharpScreenVideoRecorderScreenVideoRecorderWorkingVersionOptionsFile.cs:line 73
at ScreenVideoRecorder.Options_DB..cctor() in d:C-SharpScreenVideoRecorderScreenVideoRecorderWorkingVersionOptions_DB.cs:line 29
InnerException:

View the full article
 
Back
Top