Problem With FileOpen() and file extensions


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: Problem With FileOpen() and file extensions

Hybrid View

  1. #1
    Join Date
    Aug 2004
    Location
    Orange, California
    Posts
    1,263

    Question Problem With FileOpen() and file extensions

    I am using Visual Studio 2005 Standard Edition.
    In my VB application I am using the FileOpen() function to read in some binary data from a file.
    If I select a file like "MyFile.dat" and try to open it, the function ignores it and creates a new file without an extension, just "MyFile", and opens that one.
    So when you run the program it looks like none of your files have any data. But actually it is ignoring your files and creating new empty ones without extensions.
    As a test I copied one of my files and renamed it without the extension. When I try to open this file it works.

    So What's up wih FileOpen()????

  2. #2
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    What parameters are you using with FileOpen?

    Bear in mind that FileOpen is provided for backward compatibility only. Have you ever tried My.Computer.FileSystem.ReadAllBytes(filename)?
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

  3. #3
    Join Date
    Aug 2004
    Location
    Orange, California
    Posts
    1,263
    FileOpen(1, "MyFile.dat", OpenMode.Binary, OpenAccess.Read, OpenShare.Default)

    Actually I was going through a book, entering and using the code from there.
    They were using FileOpen(). So far, in VB.Net, I have only used FileStreams. With the appropriate reader, in this case a BinaryReader. I did not realize that FileOpen() was a replacement for the VB6, OPEN. Which explaines why FileGet and FilePut work so much like the old GET #, and PUT #...

    The data files I am using contain large blocks of integer values, Short's or Int16's. It uses FileGet() to read them into an array, and then processes the data.

    Interesting side bar here: Is there any reason to use Int16 over Short or the reverse Short over Int16?

  4. #4
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    Scroll down a little on this link. The table describes the base types that the .NET framework supplies for Integers and Floating Points.
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

  5. #5
    Join Date
    Aug 2004
    Location
    Orange, California
    Posts
    1,263
    I knew that internally they were both the same. I was just wondering if there was a preference. Based on the table. Most other languages (C#, JScript) use Short. Int16 seems more descriptive but if one does a lot of cross or mixed language developemnt, short might be better.

Similar Threads

  1. file extensions, jet & registry
    By Chris8 in forum VB Classic
    Replies: 12
    Last Post: 06-07-2004, 09:28 PM
  2. Problem with SaveDialog & File extensions
    By robertob in forum Java
    Replies: 12
    Last Post: 10-17-2003, 05:41 AM
  3. Unique File Extensions
    By anonymous in forum VB Classic
    Replies: 2
    Last Post: 07-08-2002, 01:23 PM
  4. .h file extensions and compiler tool
    By Louise in forum C++
    Replies: 5
    Last Post: 01-24-2001, 02:09 PM
  5. Replies: 2
    Last Post: 06-12-2000, 07:36 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center