Search Results

Search found 3856 results on 155 pages for 'io'.

Page 18/155 | < Previous Page | 14 15 16 17 18 19 20 21 22 23 24 25  | Next Page >

  • C# double-quoted path name being escaped when read from file

    - by KrisTrip
    I am trying to read in a text input file that contains a list of filenames (one per line). However, I am running into an issue if the user double-quotes the path (because it has a space in it). For example, a normal input file might have: C:\test\test.tiff C:\test\anothertest.tiff C:\test\lasttest.tiff These get read in fine by my code ("C:\\test\\test.tiff" etc) However, if I have the following input file: "C:\test with spaces\test.tiff" "C:\test with spaces\anothertest.tiff" "C:\test with spaces\lasttest.tiff" These get read in double-quotes and all ("\"C:\\test with spaces\\test.tiff\"" etc). This becomes a problem when I try to open the files (I understandably get invalid character exceptions). My question is, how do I fix this? I want to allow users to input quoted strings and handle them correctly. My first impression was to just write a little method that strips off beginning or ending quotes, but I thought there might be a better way.

    Read the article

  • lseek/write suddenly returns -1 with errno = 9 (Bad file descriptor)

    - by Ger Teunis
    My application uses lseek to seek the desired position to write data. The file is opened using open() command successfully and my application was able to use lseek and wite lots of times. At a given time, for some users and not easily reproducible the lseek returns -1 with an errno of 9. File is not closed before this and the filehandle (int) isn't reset. After this an other file is created open is okay again and lseek and write works again. To make it even worse, this user tried the complete sequence again and all was well. So my question is, can the OS close the file handle for me for some reason? What could cause this? A file indexer or file scanner of some sort? What is the best way to solve this; is this pseudo code the best solution? (never mind the code layout, will create functions for it) int fd=open(...); if (fd>-1) { long result = lseek(fd,....); if (result == -1 && errno==9) { close(fd..); //make sure we try to close nicely fd=open(...); result = lseek(fd,....); } } Anybody experience with something similar? Summary: file seek and write works okay for a given fd and suddenly gives back errno=9 without a reason.

    Read the article

  • C file read leaves garbage characters

    - by KJ
    Hi. I'm trying to read the contents of a file into my program but I keep occasionally getting garbage characters at the end of the buffers. I haven't been using C a lot (rather I've been using C++) but I assume it has something to do with streams. I don't really know what to do though. I'm using MinGW. Here is the code (this gives me garbage at the end of the second read): include include char* filetobuf(char *file) { FILE *fptr; long length; char *buf; fptr = fopen(file, "r"); /* Open file for reading */ if (!fptr) /* Return NULL on failure */ return NULL; fseek(fptr, 0, SEEK_END); /* Seek to the end of the file */ length = ftell(fptr); /* Find out how many bytes into the file we are */ buf = (char*)malloc(length+1); /* Allocate a buffer for the entire length of the file and a null terminator */ fseek(fptr, 0, SEEK_SET); /* Go back to the beginning of the file */ fread(buf, length, 1, fptr); /* Read the contents of the file in to the buffer */ fclose(fptr); /* Close the file */ buf[length] = 0; /* Null terminator */ return buf; /* Return the buffer */ } int main() { char* vs; char* fs; vs = filetobuf("testshader.vs"); fs = filetobuf("testshader.fs"); printf("%s\n\n\n%s", vs, fs); free(vs); free(fs); return 0; } The filetobuf function is from this example http://www.opengl.org/wiki/Tutorial2:_VAOs,_VBOs,_Vertex_and_Fragment_Shaders_%28C_/_SDL%29. It seems right to me though. So anyway, what's up with that?

    Read the article

  • Reading Binary file in C

    - by darkie15
    Hi All, I am having following issue with reading binary file in C. I have read the first 8 bytes of a binary file. Now I need to start reading from the 9th byte. Following is the code: fseek(inputFile, 2*sizeof(int), SEEK_SET); However, when I print the contents of the array where I store the retrieved values, it still shows me the first 8 bytes which is not what I need. Can anyone please help me out with this? Regards, darkie

    Read the article

  • Parse values from a text file in C

    - by Mohit Deshpande
    Say I have written to a text file in this format: key1/value1 key2/value2 akey/withavalue anotherkey/withanothervalue I have a linked list like: struct Node { char *key; char *value; struct Node *next; }; to hold the values. How would I read key1 and value1? I was thinking of putting line by line in a buffer and using strtok(buffer, '/'). Would that work? What other ways could work, maybe a bit faster or less prone to error? Please include a code sample if you can!

    Read the article

  • c#: how to read parts of a file? (DICOM)

    - by Xaisoft
    I would like to read a DICOM file in C#. I don't want to do anything fancy, I just for now would like to know how to read in the elements, but first I would actually like to know how to read the header to see if is a valid DICOM file. It consists of Binary Data Elements. The first 128 bytes are unused (set to zero), followed by the string 'DICM'. This is followed by header information, which is organized into groups. A sample DICOM header First 128 bytes: unused DICOM format. Followed by the characters 'D','I','C','M' Followed by extra header information such as: 0002,0000, File Meta Elements Groups Len: 132 0002,0001, File Meta Info Version: 256 0002,0010, Transfer Syntax UID: 1.2.840.10008.1.2.1. 0008,0000, Identifying Group Length: 152 0008,0060, Modality: MR 0008,0070, Manufacturer: MRIcro In the above example, the header is organized into groups. The group 0002 hex is the file meta information group which contains 3 elements: one defines the group length, one stores the file version and the their stores the transfer syntax. Questions How to I read the header file and verify if it is a DICOM file by checking for the 'D','I','C','M' characters after the 128 byte preamble? How do I continue to parse the file reading the other parts of the data?

    Read the article

  • Blackberry read local properties file in project

    - by Dachmt
    Hi, I have a config.properties file at the root of my blackberry project (same place as Blackberry_App_Descriptor.xml file), and I try to access the file to read and write into it. See below my class: public class Configuration { private String file; private String fileName; public Configuration(String pathToFile) { this.fileName = pathToFile; try { // Try to load the file and read it System.out.println("---------- Start to read the file"); file = readFile(fileName); System.out.println("---------- Property file:"); System.out.println(file); } catch (Exception e) { System.out.println("---------- Error reading file"); System.out.println(e.getMessage()); } } /** * Read a file and return it in a String * @param fName * @return */ private String readFile(String fName) { String properties = null; try { System.out.println("---------- Opening the file"); //to actually retrieve the resource prefix the name of the file with a "/" InputStream is = this.getClass().getResourceAsStream(fName); //we now have an input stream. Create a reader and read out //each character in the stream. System.out.println("---------- Input stream"); InputStreamReader isr = new InputStreamReader(is); char c; System.out.println("---------- Append string now"); while ((c = (char)isr.read()) != -1) { properties += c; } } catch (Exception e) { } return properties; } } I call my class constructor like this: Configuration config = new Configuration("/config.properties"); So in my class, "file" should have all the content of the config.properties file, and the fileName should have this value "/config.properties". But the "name" is null because the file cannot be found... I know this is the path of the file which should be different, but I don't know what i can change... The class is in the package com.mycompany.blackberry.utils Thank you!

    Read the article

  • fwrite = unblocking ?

    - by John Michaels
    Since you can't be sure that what you write with fwrite has been written (god thats an awesome sentence) before you call fflush can i consider fwrite a nonblocking write?? And if not, why not and what are my alternatives?

    Read the article

  • kernelHow to read/write files within kernel module?

    - by Methos
    I know all the discussions about why one should not read/write files from kernel, instead how to use /proc or netlink to do that. I want to read/write anyway. I have also read http://www.linuxjournal.com/article/8110 However, problem is 2.6.30 does not export sys_read(). Rather its wrapped in SYSCALL_DEFINE3. So if I use that in my module, I get following warnings: WARNING: "sys_read" [xxx.ko] undefined! WARNING: "sys_open" [xxx.ko] undefined! Obviously insmod cannot load the module because linking does not happen correctly. Questions: How to read/write within kernel after 2.6.22 (where sys_read()/sys_open() are not exported)? In general, how to use system calls wrapped in macro SYSCALL_DEFINEn() from within the kernel?

    Read the article

  • WML And Downloads

    - by Nathan Campos
    I'm now playing with WML and WMLScript, but I'm doing a site that will have some content to download(some txt, doc, bmp, mpg, avi and jpg files), but some of my friends(that never developed in this language, just used the technology on the beginning) said that it's impossible. Then here are my questions: It's possible? How to do it? Remember that I'm using PHP combined with WML.

    Read the article

  • read url in binary mode in java

    - by Andrew Zawok
    In java I need to read a binary file from a site and write it to a disk file. This example http://java.sun.com/docs/books/tutorial/networking/urls/readingURL.html could read webpages succesfully, but when I try to read a binary file from my localhost server and write it to a disk file the contents change, corrupting the binary file. Using fc I see that 0x90 is changed to 0x3F and other changes. How do I acess the binary files (read url and write to file) without java or anything else changing ANY characters, like doing any newline conversions or character conversions or anything else, simply reading input url and writing it out as a file.

    Read the article

  • Get PocketC File Handle Int?

    - by Nathan Campos
    I'm now taking a look at the PocketC powerful tool, but there is an fileopen function, that generates a integer called filehandle, that is used for most of the File I/O operations of PocketC, than I want to know how to discover the int filehandle from the function? Here is my example function that I'm using at my program: fileopen("\test.txt", 0, 0x00000000); Description of int filehandle: Integer used for file operations, used as a pointer to the fileopen instruction.

    Read the article

  • read a binary file (python)

    - by beratch
    Hi, I cant read a file, and I dont understand why: f = open("test/test.pdf", "r") data = list(f.read()) print data Returns : [] I would like to open a PDF, and extract every bytes, and put it in a List. What's wrong with my code ? :( Thanks,

    Read the article

  • Prevent Windows Explorer from interfering with Directory operations.

    - by Bruno Martinez
    Sometimes, no "foo" directory is left after running this code: string folder = Path.Combine(Path.GetTempPath(), "foo"); if (!Directory.Exists(folder)) Directory.CreateDirectory(folder); Process.Start(@"c:\windows\explorer.exe", folder); Thread.Sleep(TimeSpan.FromSeconds(5)); Directory.Delete(folder, false); Directory.CreateDirectory(folder); It seems Windows Explorer keeps a reference to the folder, so the last CreateDirectory has nothing to do, but then the original folder is deleted. How can I fix the code?

    Read the article

  • Parsing a file with hierarchical structure in Python

    - by Kevin Stargel
    I'm trying to parse the output from a tool into a data structure but I'm having some difficulty getting things right. The file looks like this: Fruits Apple Auxiliary Core Extras Banana Something Coconut Vegetables Eggplant Rutabaga You can see that top-level items are indented by one space, and items beneath that are indented by two spaces for each level. The items are also in alphabetical order. How do I turn the file into a Python list that's something like ["Fruits", "Fruits/Apple", "Fruits/Banana", ..., "Vegetables", "Vegetables/Eggplant", "Vegetables/Rutabaga"]?

    Read the article

  • Merging two XML files into one XML file using Java

    - by dmurali
    I am stuck with how to proceed with combining two different XML files(which has the same structure). When I was doing some research on it, people say that XML parsers like DOM or StAX will have to be used. But cant I do it with the regular IOStream? I am currently trying to do with the help of IOStream but this is not solving my purpose, its being more complex. For example, What I have tried is; public class GUI { public static void main(String[] args) throws Exception { // Creates file to write to Writer output = null; output = new BufferedWriter(new FileWriter("C:\\merged.xml")); String newline = System.getProperty("line.separator"); output.write(""); // Read in xml file 1 FileInputStream in = new FileInputStream("C:\\1.xml"); BufferedReader br = new BufferedReader(new InputStreamReader(in)); String strLine; while ((strLine = br.readLine()) != null) { if (strLine.contains("<MemoryDump>")){ strLine = strLine.replace("<MemoryDump>", "xmlns:xsi"); } if (strLine.contains("</MemoryDump>")){ strLine = strLine.replace("</MemoryDump>", "xmlns:xsd"); } output.write(newline); output.write(strLine); System.out.println(strLine); } // Read in xml file 2 FileInputStream in = new FileInputStream("C:\\2.xml"); BufferedReader br1 = new BufferedReader(new InputStreamReader(in)); String strLine1; while ((strLine1 = br1.readLine()) != null) { if (strLine1.contains("<MemoryDump>")){ strLine1 = strLine1.replace("<MemoryDump>", ""); } if (strLine1.contains("</MemoryDump>")){ strLine1 = strLine1.replace("</MemoryDump>", ""); } output.write(newline); output.write(strLine1); I request you to kindly let me know how do I proceed with merging two XML files by adding additional content as well. It would be great if you could provide me some example links as well..! Thank You in Advance..! System.out.println(strLine1); } }

    Read the article

  • Delete a line from a file in java

    - by dalton conley
    Ok, so I'm trying to delete lines from a text file with java. Currently the way I'm doing this, is I'm keep track of a line number and inputting an index. The index is the line I want deleted. So each time I read a new line of data I increment the line count. Now when I reach the line count that is the same index, I dont write the data to the temporary file. Now this works, but what if for example I'm working with huge files and I have to worry about memory restraints. How can I do this with.. file markers? For example.. place the file marker on the line I want to do delete. Then delete that line? Or is that just too much work?

    Read the article

  • Is it possible to change HANDLE that has been opened for synchronous I/O to be opened for asynchrono

    - by Martin Dobšík
    Dear all, Most of my daily programming work in Windows is nowadays around I/O operations of all kind (pipes, consoles, files, sockets, ...). I am well aware of different methods of reading and writing from/to different kinds of handles (Synchronous, asynchronous waiting for completion on events, waiting on file HANDLEs, I/O completion ports, and alertable I/O). We use many of those. For some of our applications it would be very useful to have only one way to treat all handles. I mean, the program may not know, what kind of handle it has received and we would like to use, let's say, I/O completion ports for all. So first I would ask: Let's assume I have a handle: HANDLE h; which has been received by my process for I/O from somewhere. Is there any easy and reliable way to find out what flags it has been created with? The main flag in question is FILE_FLAG_OVERLAPPED. The only way known to me so far, is to try to register such handle into I/O completion port (using CreateIoCompletionPort()). If that succeeds the handle has been created with FILE_FLAG_OVERLAPPED. But then only I/O completion port must be used, as the handle can not be unregistered from it without closing the HANDLE h itself. Providing there is an easy a way to determine presence of FILE_FLAG_OVERLAPPED, there would come my second question: Is there any way how to add such flag to already existing handle? That would make a handle that has been originally open for synchronous operations to be open for asynchronous. Would there be a way how to create opposite (remove the FILE_FLAG_OVERLAPPED to create synchronous handle from asynchronous)? I have not found any direct way after reading through MSDN and googling a lot. Would there be at least some trick that could do the same? Like re-creating the handle in same way using CreateFile() function or something similar? Something even partly documented or not documented at all? The main place where I would need this, is to determine the the way (or change the way) process should read/write from handles sent to it by third party applications. We can not control how third party products create their handles. Dear Windows gurus: help please! With regards Martin

    Read the article

  • File I/O OS handling

    - by Albinoswordfish
    This isn't a direct coding question but more of a OS handling mechanism. I was reading somebody's previous question regarding C# and file handling. Apparently C# was throwing an exception regarding a file being locked when trying to access this. So my question is, does C# use an internal lock to handle file I/O between processes, or does the OS use some type of mutual exclusion for file I/O? From what I learned about operating systems, well at least unix, is that the OS doesn't implement any type of mutual exclusion for processes trying to access the same file.

    Read the article

  • Cannot run fopen() or file_get_contents()

    - by Obay
    Hi, When I use fopen() or file_get_contents(), I get the following error: Warning: fopen(URL_OF_FILE_HERE) [function.fopen]: failed to open stream: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. in D:\WebServer\Sapphire\CMS_2009\apps\Newswire\send_mails.php on line 57 PHP version is 5.9.2-2. In another server, PHP is 5.9.2, and it works fine. allow_url_fopen is On Any ideas?

    Read the article

  • High PageIOLatch_SH Waits with High Drive Idle times

    - by Marty Trenouth
    We are experiencing high volume of PageIOLatch_SH waits on our database (row counts in the Billions). However it seems that our drive Idle time Percentage hovers around 50-60 percent. CPU usage is nill. The Database Tuning Advisor gives no suggestions for optimization. The query plan (actual) from the single stored procedure used on the database puts the majority of the expense on index seek (yeah I know these should be optimial) operations. Anyone have suggestions of how to increase throughput?

    Read the article

< Previous Page | 14 15 16 17 18 19 20 21 22 23 24 25  | Next Page >