本文介绍了其中定义了FILE_APPEND_DATA,FILE_SHARE_READ,INVALID_HANDLE_VALUE和......的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 [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);





i有这样的错误:

错误CS0103:当前上下文中不存在名称'FILE_APPEND_DATA'
错误CS0103:当前上下文中不存在名称'FILE_SHARE_READ'





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

解决方案

[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);



i have errors like this:

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



how do i solve this errors? please help me.

解决方案


这篇关于其中定义了FILE_APPEND_DATA,FILE_SHARE_READ,INVALID_HANDLE_VALUE和......的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-16 11:27