file-access

How do I access a file inside an OSGi bundle?

蓝咒 提交于 2019-12-03 23:41:49
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.0:0/myfile . But this URI can't be converted to a File-instance using the File(URI uri) constructor

Hadoop map-reduce operation is failing on writing output

别等时光非礼了梦想. 提交于 2019-12-03 17:36:11
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 same. ****hdfs://localhost:9000/user/hadoopmachine/input 12/04/03 07:29:35 INFO input.FileInputFormat:

C# Application can't read/write to files created by administrator when run in limited user account XP

a 夏天 提交于 2019-12-03 13:43:03
问题 I have an application that is useable by all users (admin or limited) in .NET (C# specifically). When the application first launches - it creates a few files that it needs in the C:\Documents and Settings\All Users\Documents\ for all subsequent launches. If the limited user in XP is the FIRST user to launch the application it creates the files fine and both the limited user and administrators can run fine. However if the Administrator (or I am guessing a different limited user) is the first

C# Application can't read/write to files created by administrator when run in limited user account XP

梦想的初衷 提交于 2019-12-03 03:46:28
I have an application that is useable by all users (admin or limited) in .NET (C# specifically). When the application first launches - it creates a few files that it needs in the C:\Documents and Settings\All Users\Documents\ for all subsequent launches. If the limited user in XP is the FIRST user to launch the application it creates the files fine and both the limited user and administrators can run fine. However if the Administrator (or I am guessing a different limited user) is the first to launch the application then the limited user is NOT able to run the application. The two files that

System.UnauthorizedAccessException was unhandled

亡梦爱人 提交于 2019-12-02 01:34:14
I am getting a access denied exception. How can I fix this? Here is the exception: System.UnauthorizedAccessException was unhandled HResult=-2147024891 Message=Access to the path 'c:\message.txt' is denied. Source=mscorlib Here is the code: public static void WriteToFile(string s) { fs = new FileStream("c:\\message.txt", FileMode.Append, FileAccess.Write); sw = new StreamWriter(fs); sw.WriteLine(s); sw.Flush(); sw.Close(); fs.Close(); } EDIT: It works if I run vs2012 as administrator, but is there a way or a reason to do it as normal user? And this works: public static void WriteToFile(string

How to check if a file is in use?

牧云@^-^@ 提交于 2019-12-01 20:36:54
问题 Is there any way to first test if a file is in use before attempting to open it for reading? For example, this block of code will throw an exception if the file is still being written to or is considered in use: try { FileStream stream = new FileStream(fullPath, FileMode.Open, FileAccess.Read, FileShare.Read); } catch (IOException ex) { // ex.Message == "The process cannot access the file 'XYZ' because it is being used by another process." } I've looked all around and the best I can find is

How to check if a file is in use?

大憨熊 提交于 2019-12-01 18:48:50
Is there any way to first test if a file is in use before attempting to open it for reading? For example, this block of code will throw an exception if the file is still being written to or is considered in use: try { FileStream stream = new FileStream(fullPath, FileMode.Open, FileAccess.Read, FileShare.Read); } catch (IOException ex) { // ex.Message == "The process cannot access the file 'XYZ' because it is being used by another process." } I've looked all around and the best I can find is to perform some sort of polling with a try catch inside, and that feels so hacky. I would expect there

File access count in Linux

只谈情不闲聊 提交于 2019-12-01 17:31:45
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? No, it is not stored. That would be a very odd feature. You can monitor access to a file and count what you need

UnauthorizedAccessException in StorageFile.OpenAsync

删除回忆录丶 提交于 2019-12-01 06:46:05
I used the following code to download/save an image and open it later, but in later OpenAsync, it throws the UnauthorizedAccessException, it seems that the file is not close, but actually the IRandomAccessStream/DataWriter has been disposed. HttpClient httpClient = new HttpClient(); HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, "http://www.silverlightshow.net/Storage/Users/nikolayraychev/Perspective_Transforms_4.gif"); HttpResponseMessage response = await httpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead); //Write Image File StorageFile imageFile =

UnauthorizedAccessException in StorageFile.OpenAsync

*爱你&永不变心* 提交于 2019-12-01 04:25:33
问题 I used the following code to download/save an image and open it later, but in later OpenAsync, it throws the UnauthorizedAccessException, it seems that the file is not close, but actually the IRandomAccessStream/DataWriter has been disposed. HttpClient httpClient = new HttpClient(); HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, "http://www.silverlightshow.net/Storage/Users/nikolayraychev/Perspective_Transforms_4.gif"); HttpResponseMessage response = await httpClient