createfile

Difference between OPEN_ALWAYS and CREATE_ALWAYS in CreateFile() of Windows API

旧巷老猫 提交于 2019-12-21 06:50:12
问题 Can anyone explain what the difference is between the creation dispositions OPEN_ALWAYS and CREATE_ALWAYS of the CreateFile() function of the windows API? To me it seems that they both simply 'create the file if it does not already exist'. 回答1: CREATE_ALWAYS also truncates the contents if the file already exists. On the other hand, OPEN_ALWAYS will not clobber an already existing file. Here's how the different values work in tabular form: | When the file... This argument: | Exists Does not

Deleting a file based on disk ID

蹲街弑〆低调 提交于 2019-12-21 03:36:10
问题 As described here, using SetFileInformationByHandle with FILE_DISPOSITION_INFO allows one to set a file with an open handle to be deleted upon all handles being closed. However, I am trying to delete a file based on its file index (disk ID) retrieved by FILE_DISPOSITION_INFO and OpenFileById in order to safely delete files/directories in a directory which differ only in case. This is safe to do in my use case, as on an NTFS system, file indexes are persistent until deletion, negating the use

Novice Batch Issue- Creating Files

被刻印的时光 ゝ 提交于 2019-12-20 07:06:49
问题 I was working on developing a batch program that would scan various sections of a PC, and log them to a file. Surprisingly, I was unable to have the program create the file to write to. I then tried to create a file, that I was fairly certain would work; it is as followed: @echo off ipconfig > ip.txt timeout 5 However, this was also unable to write to the file ip.txt . I also attempted the following program, with no success. @echo off echo Test > test.txt timeout 3 If anyone would be able to

File.createNewFile() randomly fails

醉酒当歌 提交于 2019-12-20 04:26:14
问题 I've build a simple test which creates and deletes a file (name does not change) in an infinite loop. The test does run for a couple of seconds (sometimes over 77,000 iterations!) and then fails with this exception: Exception in thread "main" java.io.IOException: Access is denied at java.io.WinNTFileSystem.createFileExclusively(Native Method) at java.io.File.createNewFile(Unknown Source) at DeleteTest.main(DeleteTest.java:11) Here's the test logic: final File f = new File(pathname); while

Create and download a text file using php

我们两清 提交于 2019-12-19 09:45:59
问题 Here's what I'm trying to do. I have a series of reports that they also want to be able to download as comma delimited text files. I've read over a bunch of pages where people say simply echo out the results rather than creating a file, but when I try that it just outputs to the page they are on. I have this in the form of each report Export File<input type="checkbox" name="export" value="1" /> So on the post I can check if they are trying to export the file. If they are I was trying to do

Create Text file from String using JS and html5

隐身守侯 提交于 2019-12-18 11:56:31
问题 i want to create a text file from a string. currently i am using a function which takes an array and makes it into a string then using that string i want to create a local text file the user downloads. i have tried using this method function createFile(){ //creates a file using the fileLIST list var output= 'Name \t Status\n'+ fileLIST[0][0].name+'\t'+fileLIST[0][1]+'\n'; var Previous = fileLIST[0]; for (var i=1; i<fileLIST.length; i++) if (fileLIST[i][1] =='none' || fileLIST[i][1] ==

“ReadFile Function” is there a way that I can no longer declare specific number of bytes to be read?

安稳与你 提交于 2019-12-13 17:24:48
问题 I'm trying to make a program using windows API in C++ The goal is to read the content of the text file that I've created and able to manipulate the content using bitwise XOR (change to lowercase and uppercase, vice versa) then put the manipulated content again inside of a text file. Here the flow of the program that I've used: Open text file using CreateFile. Put the content of the text file on a created malloc. Manipulate the content of the text file using bitwise XOR (xor = 20). Then put

Create dir with datetime name and subfiles within directory (Python)

≡放荡痞女 提交于 2019-12-13 16:03:14
问题 I'm currently looking to create a directory on Linux using Python v2.7 with the directory name as the date and time (ie. 27-10-2011 23:00:01). My code for this is below:- import time import os dirfmt = "/root/%4d-%02d-%02d %02d:%02d:%02d" dirname = dirfmt % time.localtime()[0:6] os.mkdir(dirname) This code works fine and generates the directory as requested. Nonetheless, what I'd also like to then is, within this directory create two csv files and a log file with the same name. Now as the

C++ COM port Opening, Reading and Writing

我的未来我决定 提交于 2019-12-13 06:52:36
问题 I am trying to open a COM port using Win32's CreateFile function. I have read docs at MSDN as well as on several forums on how to do that but no matter what I do I still get Error code #2 (port does not exist). The code I currently have is: m_hCom = CreateFile( "\\.\COM10", GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL ); if (m_hCom == INVALID_HANDLE_VALUE) { int error = GetLastError(); return FALSE; } I am using Visual Studio 2010. Please tell me what am I

CreateFile2 error in WinRT project (ERROR_NOT_SUPPORTED_IN_APPCONTAINER)

和自甴很熟 提交于 2019-12-12 05:38:25
问题 I just working on some file management api in WinRT. I successfully created folder in ../Packages/myApp/LocalState/ but when I try to create new file ( CreateFile2 ) in that folder I get this error 4252: ERROR_NOT_SUPPORTED_IN_APPCONTAINER This functionality is not supported in the context of an app container. code: localFolder = L"C:\\Users\\Tomas\\AppData\\Local\\Packages\\myApp\\LocalState\\my"; CreateDirectory(localFolder.c_str(),NULL); localFolder += L"\\MyFile.txt"; CREATEFILE2_EXTENDED