file-access

How to intercept the access to a file in a .NET Program

僤鯓⒐⒋嵵緔 提交于 2019-12-05 15:51:10
问题 I need to intercept when the system tries to access to a file, and do something before it happens. 回答1: You can use FileSystemWatcher - but this doesn't let you intercept the event and do things before hand - it only informs you after the fact that a particular file or directory has been affected in some way. Intercepting file access is not something you can do easily. You can write a file system filter driver, which is an unmanaged DLL which the O/S will load that can intercept operations on

How do I access a file inside an OSGi bundle?

对着背影说爱祢 提交于 2019-12-05 15:27:11
问题 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 "file"-scheme or the path as string is necessary. How do I retrieve any of those in a clean way? I tried using the context.getBundle().getResource("/myfile") (where context is of type org.osgi.framework.BundleContext ) which returns the URI bundle://6

Hadoop map-reduce operation is failing on writing output

↘锁芯ラ 提交于 2019-12-05 02:05:18
问题 I am finally able to start a map-reduce job on Hadoop (running on a single debian machine). However, the map reduce job always fails with the following error: hadoopmachine@debian:~$ ./hadoop-1.0.1/bin/hadoop jar hadooptest/main.jar nl.mydomain.hadoop.debian.test.Main /user/hadoopmachine/input /user/hadoopmachine/output Warning: $HADOOP_HOME is deprecated. 12/04/03 07:29:35 WARN mapred.JobClient: Use GenericOptionsParser for parsing the arguments. Applications should implement Tool for the

UnauthorizedAccessException on creating file after deletion using FileStream

半城伤御伤魂 提交于 2019-12-04 20:57:39
I am facing an issue on client system. On trying to reproduce it in a sample code I have reproduced it. Here's the sample code Imports System.IO Public Class Form1 Private _lock As New Object Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim t As New Threading.Thread(AddressOf createFile) With t .IsBackground = True .Name = Guid.NewGuid.ToString .Start() End With End Sub Private Sub createFile() Dim path As String = "D:\SomeFile.txt" For i As Integer = 0 To 1000 SyncLock _lock If File.Exists(path) Then File.Delete(path) Using fs As

Python get last reading time of a file [duplicate]

。_饼干妹妹 提交于 2019-12-04 18:51:45
This question already has an answer here: Get last access time of the file? 2 answers I'm looking for a solution to get the time a file was read at last. The file will be not modified or created just opened in reading mode. This works but only for writing in a file. If I open the file in read mode, the time is not correct: f = open('my_path/test.txt', 'r') f.close() print time.ctime(os.stat('my_path/test.txt').st_mtime) Any hints? You are looking at the wrong entry in the stat structure. You want to use the .st_atime value instead: print time.ctime(os.stat('my_path/test.txt').st_atime) From

What is sys.stdin.fileno() in python

旧街凉风 提交于 2019-12-04 18:04:07
问题 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 block, fileno = sys.stdin.fileno() if fileno is not None: new_stdin = os.fdopen(os.dup(fileno)) I just executed print sys.stdin.fileno() in my python command line and it returned 0 . I also searched google, and this (nullage.com) is the reference I could

File access, unit testing, dependency injection

江枫思渺然 提交于 2019-12-04 17:46:18
I've recently asked a question regarding best ways of separating business logic from data access to make application testable ( here ). Thanks to Jeff Sternal, I've created interface for the data access and passing its concrete implementation from the application top level to BL. But now I'm trying to figure out how can I separate file access methods from business logic. Let's say I have a function that loads data from a database into dataset, formats loaded data (formats are stored in some external xml file) and finally serializes dataset to a file. So, to support testability I need to move

What is the difference between file and random access file?

橙三吉。 提交于 2019-12-04 11:29:13
what is the difference between file and random access file? A random access file is a file where you can "jump" to anywhere within it without having to read sequentially until the position you are interested in. For example, say you have a 1MB file, and you are interested in 5 bytes that start after 100k of data. A random access file will allow you to "jump" to the 100k-th position in one operation. A non-random access file will require you to read 100k bytes first, and only then read the data you're interested in. Hope that helps. Clarification: this description is language-agnostic and does

UWP apps accessing files from random location on system

ε祈祈猫儿з 提交于 2019-12-04 09:37:17
in UWP there are files and permissions restrictions, so we can only acces files directly from few folders or we can use filepicker to access from anywhere on system. how can I use the files picked from filepicker and use them anytime again when the app runs ? tried to use them again by path but it gives permission error. I know about the "futureacceslist" but its limit is 1000 and also it will make the app slow if I am not wrong? . Is there a better way to do this ? or can we store storage files link somehow in local sqlite database? Considering this method.. public async static Task<byte[]>

File access count in Linux

家住魔仙堡 提交于 2019-12-04 03:17:50
问题 Is there a way how to effectively determine the number of accesses to a specific file and the process which accessed it without storing the access info by a 3rd party software? I'm looking for something built in inside the linux-based operating systems. The date of the last change is pretty obvious but I need information at least on how many times it was accessed since the creation of the file. Can anyone shed some light on this file accessing information? Is it stored somewhere? 回答1: No, it