file-access

Howto synchronize file access in a shared folder using Java (OR: ReadWriteLock on network level)

笑着哭i 提交于 2019-11-28 01:00:56
问题 I have multiple applications running in one virtual machine. I have multiple virtual machines running on one server. And I have multiple servers. They all share a file using a shared folder on linux. The file is read and written by all applications. During the write process no application is allowed to read this file. The same for writing: If an application is reading the file no application is allowed to write it. How do I manage to synchronize the applications so they will wait for the

How do i resolve EXC_BAD_ACCESS errors encountered in iphone development

与世无争的帅哥 提交于 2019-11-27 20:25:26
问题 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 read it back i get an EXC_BAD_ACCESS error in GDB that i have no idea how to resolve. Here is what my code basically looks like: -(UIImage *) downloadImageToFile { NSURL * url = [[NSURL alloc] initWithString: self.urlField.text]; NSArray *paths =

File is used by another process. How to know which process?

一曲冷凌霜 提交于 2019-11-27 18:13:35
问题 I keep getting that exception in my program. How do I know which process locked it, either by program code or by doing something with windows? System.IO.IOException : The process cannot access the file 'file.ext' because it is being used by another process. 回答1: You can use ProcessExplorer to search for the file: http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx Just run that (maybe you need to launch it with administrator rights), hit Ctrl-F and type in the name of the file which

How do I restrict access to files with specific extensions in ASP.NET?

梦想的初衷 提交于 2019-11-27 18:01:02
问题 I have in my web application an ADO.NET Entity-Framework *.edmx file. When I browse in the browser (when the application is running) to an edmx file, it doesn't show the error page like when browsing to a *.cs or vb file, it opens the edmx and shows my model scheme to all the users!!! How can I avoid that. 回答1: You can do this two ways; firstly in the web.config or secondly in IIS <system.web> <httpHandlers> <add verb="*" path="*.edmx" type="System.Web.HttpForbiddenHandler" /> </httpHandlers>

Denying direct access to a folder (only allow through app)

白昼怎懂夜的黑 提交于 2019-11-27 16:58:58
问题 I need to prevent someone from directly accessing a pdf, instead only allowing them to be pulled through the app itself. How can this be done? 回答1: Check my blog post about this: How to hide users files and folders on your website? There are two solutions for doing that: 1- You can put your “UsersUploads” folder outside the website directory, so if your website exist on “c:\website\example.com” you can put the “UsersUploads” there “c:\UsersUploads”, Like that IIS has no control over this

How to to make a file private by securing the url that only authenticated users can see

折月煮酒 提交于 2019-11-27 13:14:09
问题 I was wondering if there is a way to secure an image or a file to be hidden when it is not authenticated. Suppose there is an image in my website which can only be seen if that user is authenticated. But the thing is I can copy the url or open the image in the new tab. http://siteis.com/media/uploaded_files/1421499811_82_Chrysanthemum.jpg And again, even if I am not authenticated, I can view that particular image by going to that url. So, my my problem is, how do I secure the files, so that

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

笑着哭i 提交于 2019-11-27 11:44:20
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 get an DirectoryNotFoundException thrown. So .. given a path, how can we recursively create all the folders necessary to create the file .. for that path? If Temp or Bar folders exists, but Foo doesn't... then that is created also. For simplicity, lets assume there's no Security concerns -- all permissions are fine, etc. Christopher B. Adkins

How to access a variable across two files

戏子无情 提交于 2019-11-27 02:19:57
问题 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 'global.php'; Now i want to set the value of $filename in test.php and the same value i want to read in test1.php. I tried with session variables as well but due to two different files i am not able to capture the variable. How to achieve this........

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

萝らか妹 提交于 2019-11-26 16:13:45
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 the directory causes an access issue. Occasionally, the first file doesn't even parse. There is only one application running and watching this directory. Eventually, this process will be running on multiple machines and they will be watching a shared directory but only one server can parse each file as the data is imported into a database and there are

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

和自甴很熟 提交于 2019-11-26 09:00:46
问题 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 is: The process cannot access the file \'D:\\temp\\1000000045.zip\' because it is being used by another process. I do not want to create a new file, I just want to copy it or delete it. Is this possible? 回答1: An Example (note: I just combined two