问题标签 [createfile]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
2 回答
5043 浏览

c# - C# 中的 Windows CreateFile 返回无效句柄

我试图在 C# 应用程序中从 Kernel32.dll 调用 CreateFile 方法,并且每次都返回无效句柄。我已经看遍了,找不到解决这个问题的方法。以下是相关代码:

常数:

导入方法:

加载驱动程序的方法:

任何人都可以帮我解决问题吗?

0 投票
1 回答
1530 浏览

file - FILE_FLAG_POSIX_SEMANTICS 做什么?

我知道这FILE_FLAG_POSIX_SEMANTICS允许文件名区分大小写,但它没有被命名的事实FILE_FLAG_CASE_SENSITIVE让我认为它可能做得更多。

它还有什么作用,还是我分析得太深入了?

0 投票
2 回答
3531 浏览

android - createNewFile() 抛出错误

在我的 android 应用程序中,我尝试在 sdcard 上创建一个 xml 文件。我试过这个:

但在 LogCat 我得到这个:

哪里有问题?为什么 createNewFile() 会抛出 IOException?需要帮助,请...

0 投票
2 回答
628 浏览

android - Android上文件名中的外来字符

当路径不包含以下字符时,这段代码有效:“ąóźżę”(波兰语中的特殊字符)。如果路径包含其中任何一个fos.write有效但没有效果(新文件不是使用“外来”路径名创建的,但路径存在)。我的问题是:我能做些什么来解决它?

“Astro”、“文件管理器”等文件管理器应用程序可以毫无问题地使用这些字符。

我也试试这个:

但它也不起作用。

0 投票
4 回答
2541 浏览

c++ - Windows WriteFile problem when using threads

My company is developing a hardware that needs to communicate with software. To do this, we have made a driver that enables writing to and reading from the hardware. To access the driver, we use the command:

Reading and writing is done using the functions:

and

And finally, CloseHandle(device), to close the file.

This works just fine in the case where the functions are called from the main thread. If they are called from some other thread, we get error 998 (no_acccess) when trying to Write more than a couple of elements. The threads are created using

I'm running out of ideas here, any suggestions?

edit: When running the following sequence:

Main_Thread succeeds and Thread_B does not. However, when writing small sets of data, this works fine. May this be because Thread_B does not inherit all of Main_Thread's access privileges?

edit2: a lot of good thinking going on here, much appreciated! After some work on this problem, the following seems to be the case:

The api contains a Queue-thread, handling all packages going to and from the device. This thread handles pointers to package-objects. When a pointer reaches the front of the queue, a "send_and_get" function is called. If the arrays in the package is allocated in the same thread that calls the "send_and_get" function, everything works fine. If the arrays are allocated in some other thread, sending fails. How to fix this, though, I don't know.

0 投票
2 回答
330 浏览

iphone - 从字符串创建 plist 文件

我有这个字符串:

我想用这个内容创建一个 plist 文件。我试过这个:

我的控制台显示:

但不要创建任何文件。

0 投票
2 回答
3960 浏览

java - 使用 JNA 调用 CreateFile 给出 UnsatisfiedLinkError: Error looking up function 'CreateFile': The specified procedure could not be found

我正在尝试CreateFile使用 JNA 在 Windows 7 上调用 Win32 的函数,目的是对该答案进行 Java 实现,以检查文件是否正在被另一个进程使用。

我到目前为止的代码是:

但是,运行它会引发异常:

java.lang.UnsatisfiedLinkError: Error looking up function 'CreateFile': The specified procedure could not be found.

如果我"kernel32"loadLibrary调用更改为无效的东西,那么我会得到The specified module could not be found这样的结果,这表明从库路径中正确找到了 DLL,但是我调用的方式有问题CreateFile

任何想法我做错了什么?


CreateFile定义com.sun.jna.examples.win32.Kernel32为:

0 投票
2 回答
3562 浏览

command-line - MacVim:使用 `alias mvim="open -a macvim"` 从命令行创建新文件

当我使用vim newfilename打开一个文件并且该文件不退出时,vim将创建一个名为newfilename.

但是,MacVim这种方式不起作用 --- 即mvim newfilename( alias mvim="open -a macvim") 会导致错误:newfilename does not exist

有没有办法配置MacVim这样mvim newfilename( alias mvim="open -a macvim") 将创建一个新文件并打开它?

0 投票
3 回答
909 浏览

android - 在android中创建文件的问题

我想做一个简单的操作。在android中创建一个文件,但我不知道为什么。android 没有创建这个文件。Android 在调试 2 和调试 3 之间停止。未创建文件夹。我不明白为什么。

我已经测试了这段代码

有了这段代码,我在创建文件时没有问题,但如果我用 Windows 资源管理器搜索,我找不到这个文件。

0 投票
1 回答
15839 浏览

winapi - CreateFile() 返回 INVALID_HANDLE_VALUE 但 GetLastError() 是 ERROR_SUCCESS

我正在使用CreateFile()打开一个串行端口。我有一个测试用例(太复杂而无法重新分发),它始终会导致CreateFile()returnINVALID_HANDLE_VALUEGetLastError()return ERROR_SUCCESS。从表面上看,只有当一个线程在另一个端口关闭它的同时打开该端口时,才会出现此错误。打开端口的线程遇到了这个问题。

我不知道这是否会有所不同,但稍后在代码中,我使用CreateIoCompletionPort将端口与 CompletionPort 相关联。

这是我的代码:

我很确定这种事情不应该发生。我做错什么了吗?如何让 API 返回正确的结果?


更多详细信息:此代码取自我开发的串行端口库:JPeripheral

这是实际的(未经处理的)源代码:

这是我得到的实际输出: