Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 其中定义了文件\附加\数据、文件\共享\读取、无效\句柄\值和_C# - Fatal编程技术网

C# 其中定义了文件\附加\数据、文件\共享\读取、无效\句柄\值和

C# 其中定义了文件\附加\数据、文件\共享\读取、无效\句柄\值和,c#,C#,我有这样的错误: [DllImport("kernel32.dll", SetLastError = true)] public static IntPtr CreateFile( string lpFileName, uint dwDesiredAccess, uint dwShareMode, IntPtr lpSecurityAttributes, uint dwCreationDisposition,

我有这样的错误:

[DllImport("kernel32.dll", SetLastError = true)]
        public static IntPtr CreateFile(
            string lpFileName, uint dwDesiredAccess,
            uint dwShareMode, IntPtr lpSecurityAttributes,
            uint dwCreationDisposition,
            uint dwFlagsAndAttributes, IntPtr hTemplateFile);

 private IntPtr m_fileHandle;

m_fileHandle = CreateFile(m_logPath ,FILE_APPEND_DATA, FILE_SHARE_READ, NULL,                                OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL|FILE_FLAG_SEQUENTIAL_SCAN|FILE_FLAG_WRITE_THROUGH,NULL);

如何解决此错误?请帮帮我

pinvoke.net:我必须定义所有文件\附加\数据、文件\共享\读取和。。。在我的项目中?@nabegheh95是的,C编译器需要知道什么是文件\附加\数据。将enum EFileAccess的整个定义复制到项目中。它们在Windows SDK头文件中定义。它对你来说很好,它只能被C或C++编译器使用。Pinvoke互操作助手是一个方便的工具,可以将它们输入到代码中。请注意,像这样的pinvoking CreateFile没有任何意义,.NET FileStream类已经完全包装了它。唯一的异常是PinVok打开设备,这是.NET所不允许的,因为它无法判断这样做是否安全,这不是打开日志文件时要做的。
error CS0103: The name 'FILE_APPEND_DATA' does not exist in the current context
error CS0103: The name 'FILE_SHARE_READ' does not exist in the current context