Questions tagged [createfile]

The Windows CreateFile API function

The Windows CreateFile API function.

Use this tag only in conjunction with the windows-specific API. Do not use this tag if you intend to refer to the generic concept of referring to a file.

474 questions
142
votes
2 answers

How to create empty folder in java?

I tried to use the File class to create an empty file in a directory like "C:/Temp/Emptyfile". However, when I do that, it shows me an error : "already made folder Temp". Otherwise, it won't create one for me. So, how do I literally create folders…
user385261
  • 4,069
  • 8
  • 26
  • 24
119
votes
9 answers

Create a file if it doesn't exist

I'm trying to open a file, and if the file doesn't exist, I need to create it and open it for writing. I have this so far: #open file for reading fn = input("Enter file to open: ") fh = open(fn,'r') # if file does not exist, create it if (!fh) fh =…
Miguel Hernandez
  • 1,209
  • 2
  • 9
  • 3
63
votes
9 answers

Creating new file through Windows Powershell

I have googled for the below question, but could not find any answer. Can someone help me on this; What is the command to create a new file through Windows Powershell?
JR Sahoo.'JS'
  • 1,338
  • 2
  • 10
  • 11
32
votes
5 answers

Creating a Random File in C#

I am creating a file of a specified size - I don't care what data is in it, although random would be nice. Currently I am doing this: var sizeInMB = 3; // Up to many Gb using (FileStream stream = new FileStream(fileName,…
Jason
  • 11,435
  • 24
  • 77
  • 131
32
votes
5 answers

cannot convert parameter 1 from 'char' to 'LPCWSTR'

I keep getting this error: cannot convert parameter 1 from 'char' to 'LPCWSTR' int main(int argc, char argv[]) { // open port for I/O HANDLE h = CreateFile(argv[1],GENERIC_READ|GENERIC_WRITE,0,NULL,OPEN_EXISTING,0,NULL); if(h ==…
sebastian
  • 1,528
  • 8
  • 26
  • 38
31
votes
2 answers

PHP create file for download without saving on server

Ultimate goal: I want to create a webpage where a user can enter information in forms. With that information I want to create a html file (below called test-download.html) by inserting the information given into a template and then force a download.…
Thomas
  • 1,085
  • 5
  • 19
  • 33
30
votes
11 answers

Create file with command line in Node

So I'm attempting to do this Node.js tutorial, and it says to create three .js files from the command line. touch server.js client.js test.js Except I get the following error: 'touch' is not recognized as an internal or external command, operable …
ckpepper02
  • 3,297
  • 5
  • 29
  • 43
29
votes
1 answer

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

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'.
Kristian Spangsege
  • 2,903
  • 1
  • 20
  • 43
19
votes
4 answers

Create Text file from String using JS and html5

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…
GreenGiant
  • 491
  • 1
  • 4
  • 13
16
votes
5 answers

How to create file directories and folders in Android data/data/project filesystem

I am working on a video editor program and am fairly new to android and java. What I would like to happen is when the user presses "create new project" button, a dialog pops up asking the user for the name of the project. I have that part down, but…
Garren
  • 231
  • 1
  • 3
  • 6
15
votes
7 answers

Is it possible to change HANDLE that has been opened for synchronous I/O to be opened for asynchronous I/O during its lifetime?

Most of my daily programming work in Windows is nowadays around I/O operations of all kind (pipes, consoles, files, sockets, ...). I am well aware of different methods of reading and writing from/to different kinds of handles (Synchronous,…
14
votes
2 answers

makedirs gives OSError: [Errno 13] Permission denied: '/pdf_files'

I'm trying to create a folder inside a folder, first I check if that directory exists and create it if necessary: name = "User1" if not os.path.exists("/pdf_files/%s" % name): os.makedirs('/pdf_files/%s' % name ) Problem is that i'm getting an…
Babel
  • 589
  • 2
  • 9
  • 23
13
votes
4 answers

Deleting a file based on disk ID

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)…
Alyssa Haroldsen
  • 3,652
  • 1
  • 20
  • 35
12
votes
2 answers

Reading a File while it is being written by another process

I'm trying to read binary data from a buffer file which is continuously written to by a different process (that I cannot modify). I'm using the following code in order to open the file: fileH = CreateFileA((LPCSTR)filename, …
user1447407
  • 129
  • 1
  • 1
  • 4
11
votes
5 answers

Figuring which printer name corresponds to which device ID

My goal is to open a printer connected via USB using the CreateFile (and then issue some WriteFiles and ReadFiles). If the printer was an LPT one, I would simply do CreateFile("LPT1:", ...). But for USB printers, there is a special device path that…
GSerg
  • 76,472
  • 17
  • 159
  • 346
1
2 3
31 32