Questions tagged [file-access]

Questions about programmatically accessing individual files. For questions about accessing a file system, use [filesystem-access]. Use either of these in conjunction with the applicable tag such as [contention], [security] or [capacity] to indicate the focus of the question.

Questions about programmatically accessing individual files. For questions about accessing a file system, use . Use either of these in conjunction with the applicable tag such as , or to indicate the focus of the question.

510 questions
201
votes
14 answers

Local file access with JavaScript

Is there local file manipulation that's been done with JavaScript? I'm looking for a solution that can be accomplished with no install footprint like requiring Adobe AIR. Specifically, I'd like to read the contents from a file and write those…
Jared
  • 5,977
  • 10
  • 38
  • 48
168
votes
9 answers

How do I create a file AND any folders, if the folders don't exist?

Imagine I wish to create (or overwrite) the following file :- C:\Temp\Bar\Foo\Test.txt Using the File.Create(..) method, this can do it. BUT, if I don't have either one of the following folders (from that example path, above) Temp Bar Foo then I…
Pure.Krome
  • 84,693
  • 113
  • 396
  • 647
145
votes
1 answer

Notepad beats them all?

On a Windows Server 2012 R2 system, a Kotlin program uses FileChannel.tryLock() to hold an exclusive lock on a file, like this: val fileRw = RandomAccessFile(file, "rw") fileRw.channel.tryLock() With this lock in place, I cannot open the file…
MonoThreaded
  • 11,429
  • 12
  • 71
  • 102
114
votes
6 answers

how can you easily check if access is denied for a file in .NET?

Basically, I would like to check if I have rights to open the file before I actually try to open it; I do not want to use a try/catch for this check unless I have to. Is there a file access property I can check before hand?
Horas
  • 1,781
  • 3
  • 16
  • 11
45
votes
7 answers

How to copy a file while it is being used by another process

Is it possible to copy a file which is being using by another process at the same time? I ask because when i am trying to copy the file using the following code an exception is raised: System.IO.File.Copy(s, destFile, true); The exception raised…
Vir
  • 1,294
  • 1
  • 13
  • 23
42
votes
9 answers

File access error with FileSystemWatcher when multiple files are added to a directory

I am running into an issue with a FileSystemWatcher when multiple files are placed into the watched directory. I want to parse the file as soon as it is placed in the directory. Typically, the first file parses fine, but adding a second file to…
Tai Squared
  • 12,273
  • 24
  • 72
  • 82
42
votes
3 answers

Android 10: What are my options to save files on external storage into a directory called "/sdcard/my-app/"

Up until Android Pie I always stored files which the app needed to get stored on /sdcard/my-app/, which I got via File fBaseDir = new File(Environment.getExternalStorageDirectory(), "my-app"); One of my App stores hundreds (up to multiple thousands)…
Daniel F
  • 13,684
  • 11
  • 87
  • 116
22
votes
3 answers

I need help understanding PowerShell security and file access issues

I'm working with PowerShell, running a script (from my console) that includes this line: $inpath = "C:\users\xxxxx\path\foo\bar" and I keep getting this error: Get-Content : Access to the path 'C:\users\xxxxx\path\foo\bar' is denied. At…
dwwilson66
  • 6,806
  • 27
  • 72
  • 117
19
votes
2 answers

Docker COPY command give 777 access to the copied file

In my docker file I have below command: USER gerrit COPY gerrit-default-config /var/gerrit/etc/gerrit.config Running the image I see that the file access number is 777. Is it default value? Is there a way to change the access other than running…
Sara
  • 2,308
  • 11
  • 50
  • 76
17
votes
3 answers

What is sys.stdin.fileno() in python

I am sorry if it's very basic or already asked before (I googled but couldn't find a simple & satisfactory explanation). I want to know what sys.stdin.fileno() is? I saw it in a code and didn't understand what it does. Here's the actual code…
Codebender
  • 14,221
  • 7
  • 48
  • 85
16
votes
3 answers

How do I access a file inside an OSGi bundle?

I am new to OSGi and created an OSGi-bundle which I run in the Apache Felix OSGi-container. There is a file resource contained in the bundle, which I need to pass to a method as a java.io.File. To instantiate a File-object, either an URI in the…
mtsz
  • 2,725
  • 7
  • 28
  • 41
16
votes
4 answers

Check if I can write a file to a directory or not with Python

I need to check if I can write a file to a directory that user point to with Python. Is there an way to check it in advance? I may be using try .. catch for this purpose, but I expect something better in the sense that I can check in advance.
prosseek
  • 182,215
  • 215
  • 566
  • 871
15
votes
8 answers

How do i resolve EXC_BAD_ACCESS errors encountered in iphone development

I'm trying to do a simple thing; read an image from the internet, save it to the app's documents directory on the iphone, and read it back from that file so that i can do other things with it later. Writing the file works fine but when i try to…
Kevlar
  • 8,804
  • 9
  • 55
  • 81
15
votes
3 answers

How to access a variable across two files

I have three files - global.php, test.php, test1.php Global.php $filename; $filename = "test"; test.php $filename = "myfile.jpg"; echo $filename; test1.php echo $filename; I can read this variable from both test and test1 files by include…
user2688512
  • 161
  • 1
  • 1
  • 5
13
votes
4 answers

Checking if a file is in use without try catch?

Is there a way I can check if a file is in use or is not opened by other process without just trying to open it and catching an exception? Is there no service method to test such a thing?
CloudyMarble
  • 36,908
  • 70
  • 97
  • 130
1
2 3
33 34