fork download
  1. using System;
  2. using System.IO;
  3.  
  4. public class Test002
  5. {
  6. public static void Main()
  7. {
  8. string basePath = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
  9. string textPath = Path.Combine(basePath, "hoge.txt");
  10. File.WriteAllText(textPath, "ほげ");
  11. Console.WriteLine(File.ReadAllText(textPath));
  12. }
  13. }
  14.  
Runtime error #stdin #stdout #stderr 0.03s 15180KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Unhandled Exception:
System.UnauthorizedAccessException: Access to the path "/home/Nm8BOM/hoge.txt" is denied.
  at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean anonymous, System.IO.FileOptions options) [0x0025f] in <8f2c484307284b51944a1a13a14c0266>:0 
  at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.IO.FileOptions options, System.String msgPath, System.Boolean bFromProxy, System.Boolean useLongPath, System.Boolean checkHost) [0x00000] in <8f2c484307284b51944a1a13a14c0266>:0 
  at (wrapper remoting-invoke-with-check) System.IO.FileStream:.ctor (string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare,int,System.IO.FileOptions,string,bool,bool,bool)
  at System.IO.StreamWriter.CreateFile (System.String path, System.Boolean append, System.Boolean checkHost) [0x00022] in <8f2c484307284b51944a1a13a14c0266>:0 
  at System.IO.StreamWriter..ctor (System.String path, System.Boolean append, System.Text.Encoding encoding, System.Int32 bufferSize, System.Boolean checkHost) [0x00061] in <8f2c484307284b51944a1a13a14c0266>:0 
  at System.IO.StreamWriter..ctor (System.String path, System.Boolean append, System.Text.Encoding encoding, System.Int32 bufferSize) [0x00000] in <8f2c484307284b51944a1a13a14c0266>:0 
  at System.IO.StreamWriter..ctor (System.String path, System.Boolean append, System.Text.Encoding encoding) [0x00000] in <8f2c484307284b51944a1a13a14c0266>:0 
  at (wrapper remoting-invoke-with-check) System.IO.StreamWriter:.ctor (string,bool,System.Text.Encoding)
  at System.IO.File.WriteAllText (System.String path, System.String contents, System.Text.Encoding encoding) [0x00000] in <8f2c484307284b51944a1a13a14c0266>:0 
  at System.IO.File.WriteAllText (System.String path, System.String contents) [0x00007] in <8f2c484307284b51944a1a13a14c0266>:0 
  at Test002.Main () [0x0001c] in <8bfc826e87fc4a19ba1972cbe5edf7ca>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.UnauthorizedAccessException: Access to the path "/home/Nm8BOM/hoge.txt" is denied.
  at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean anonymous, System.IO.FileOptions options) [0x0025f] in <8f2c484307284b51944a1a13a14c0266>:0 
  at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.IO.FileOptions options, System.String msgPath, System.Boolean bFromProxy, System.Boolean useLongPath, System.Boolean checkHost) [0x00000] in <8f2c484307284b51944a1a13a14c0266>:0 
  at (wrapper remoting-invoke-with-check) System.IO.FileStream:.ctor (string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare,int,System.IO.FileOptions,string,bool,bool,bool)
  at System.IO.StreamWriter.CreateFile (System.String path, System.Boolean append, System.Boolean checkHost) [0x00022] in <8f2c484307284b51944a1a13a14c0266>:0 
  at System.IO.StreamWriter..ctor (System.String path, System.Boolean append, System.Text.Encoding encoding, System.Int32 bufferSize, System.Boolean checkHost) [0x00061] in <8f2c484307284b51944a1a13a14c0266>:0 
  at System.IO.StreamWriter..ctor (System.String path, System.Boolean append, System.Text.Encoding encoding, System.Int32 bufferSize) [0x00000] in <8f2c484307284b51944a1a13a14c0266>:0 
  at System.IO.StreamWriter..ctor (System.String path, System.Boolean append, System.Text.Encoding encoding) [0x00000] in <8f2c484307284b51944a1a13a14c0266>:0 
  at (wrapper remoting-invoke-with-check) System.IO.StreamWriter:.ctor (string,bool,System.Text.Encoding)
  at System.IO.File.WriteAllText (System.String path, System.String contents, System.Text.Encoding encoding) [0x00000] in <8f2c484307284b51944a1a13a14c0266>:0 
  at System.IO.File.WriteAllText (System.String path, System.String contents) [0x00007] in <8f2c484307284b51944a1a13a14c0266>:0 
  at Test002.Main () [0x0001c] in <8bfc826e87fc4a19ba1972cbe5edf7ca>:0