file

C#: Check if a file is not locked and writable

Hi I want to check if a list of files is in use or not writable before I start replacing files. Sure I know that the time from the file-check and the file-copy there is a chance that one or more files is gonna to be locked by someone else but i handle those exceptions. I want to run this test before file copy because the complete list o...

File uploading : What should be the files name to save ?

I am going to add file upload control to my ASP.NET 2.0 web page so that users can upload files.Files will be stored in the server in the folder with the name as of the user. I want to know what is the best option to name the files when saving to server. Needs to consider Security,Performance,Flexibility to handle files etc... .If i mis...

C# find most recent file in dir

I need to find the most recently modified file in a directory. I know I can loop through every file in a folder and compare File.GetLastWriteTime but is there a better way to do this without looping? ...

How can I safely encode a string in Java to use as a filename ?

I'm receiving a string from an external process. I want to use that String to make a filename, and then write to that file. Here's my code snippet to do this: String s = ... // comes from external source File currentFile = new File(System.getProperty("user.home"), s); PrintWriter currentWriter = new PrintWriter(currentFile);...

Is it possible to define a pointer to a character inside a text file?

Say we have opened a text file. Is it possible to define a pointer to a character in the file? If it is - will the following characters in the file appear in memory in the same order they appear in the file? The reason I ask: I need to process a text file. I read one line at a time and there are certain strings I want to keep. The buffe...

Program needed to display graph of tab delimited file on web in real time

What I need is a method to display a graph of data from a tab delimited file uploaded to a website. Once the file is uploaded the program will convert the data to a graph or the graph be generated locally and sent to website, but it needs to be automated and in realtime. Thanks, Antone ...

Store options in database or in a file?

Hello, in a client-server database application, the different options the client needs to read from the server, where you'd store them? In the database or in some file which will then will be transferred on the network, or is there any better way. ...

HttpModule/HttpApplication testing whether url is a request for a file

Hi, Within a HttpModule I would like to check whether the url ends with a file: ie. www.example.com/images/images.css and what the file extension is ie. css or js In the Begin_Request event handler, using the Url property of the Request object nested in the HttpApplication, I am currently cutting of the file extension using String op...

How to open python source files using the IDLE shell?

If I import a module in IDLE using: import <module_name> print <module_name>.__file__ how can I open it without going through the Menu->File->Open multiple-step procedure? It would be nice to open it via a command that takes the path and outputs a separate editor like IDLE. ...

What's the difference between the four File Results in ASP.NET MVC

ASP.NET has four different types of file results: FileContentResult: Sends the contents of a binary file to the response. FilePathResult: Sends the contents of a file to the response FileResult: Returns binary output to write to the response FileStreamResult: Sends binary content to the response by using a Stream instance Those d...

php function to split an array at each blank line?

Hello, I'm building a script which will open a saved text file, export the contents to an array and then dump the contents in a database. So far I've been able to get the file upload working quite happily and can also open said file. The trouble I'm having is the contents of the file are variable, they have a fixed structure but the co...

Hide a file or directory using the Windows API from C

I want to modify a C program to make some of the files it creates hidden in Windows. What Windows or (even better) POSIX API will set the hidden file attribute? ...

How to delete last line of file in Ruby?

Hey guys, probably a simple question but my google-fu is failing me and does not seem to be posted on SO yet... I basically have a file I am accessing and before I append to it I want to delete the last line from the file. Is there any efficient way of doing this in Ruby? This is what I am using to access the file: file = File.new("im...

Why segfault on fclose?

I'm clearly missing something. Could someone please explain why this would happen? #define RANDOM_DEVICE "/dev/random" int create_shared_secret(char * secret,int size) { FILE * file=NULL; int RetVal; file=fopen(RANDOM_DEVICE,"r"); if(!file) { printf("Unable to open random device %s\n",RANDOM_DEVICE); exit(-1); } R...

struts1,properties file

hi, i have a selection box in struts1 jsp file.In that box the key values i have to get from the properties file.Any idea please Thanks Usman.sk ...

Which reasons could make ShellExecute fail?

I have a VB6 application which opens files with their associated application using: ShellExecute(0, "open", filename, params, vbNullString, vbNormalFocus) This works perfectly. Now I got a customer (running XP with Adobe Reader) who can't open any PDF file using the above command. But the same file is being opened without any proble...

Error while uploading a file from the c# code

Hi, I am uploading an excel sheet from the code. When I am trying it from local system, its working fine but after deploying the website into IIS, when I am trying to upload the file the following error is thrown : "Upload Error : Cannot access a closed file" Please help in this. Thanks Rupa ...

File Type CBK - Not Cardscan

Is there a way to open a cbk file to see what application created it? I know that if it was a .net application it would have a CLI header that would give some insight. Is there a Win application that will allow us to see this? I know it is not a cardscan backup, but definetly is a database of some sort, just need to figure out what ...

Flex : forcing extension on a file name

In flex when I allow user to download a file using : dwFile = new FileReference(); dwFile.download(downloadURL, dwFileName); Is there a way to ensure that the downloaded file always ends up with the extension .tar or any other extension for that matter? By default I give it a name like xyz.tar, but as of now t...

I want to put a check that does not delete my drives that is C:\ and D:\ drive on my machine

I have a piece of code that saves my processed file at a location. If there is data at that file that is any subdirectory or files then the directory is first deleted and then processed file is stored there. Now if i give the path as C:\ then all the data in C:\ drive will get deleted. I dont want this. I want to put a check if the locat...