Using filestream without opening the file

Sir
I am trying to save a file to the SQL database using the following code. The code runs successfully but the file opens up during the process.
Dim fs As FileStream
fs = New FileStream(strFileName, FileMode.Open, FileAccess.Read)
Dim docByte As Byte() = New Byte(fs.Length - 1) {}
fs.Read(docByte, 0, System.Convert.ToInt32(fs.Length))
fs.Close()
I do not want the file to open. Any suggestion. Please help me
Regards
Manoj

Sir
I am trying to save a file to the SQL database using the following code. The code runs successfully but the file opens up during the process.
Dim fs As FileStream
fs = New FileStream(strFileName, FileMode.Open, FileAccess.Read)
Dim docByte As Byte() = New Byte(fs.Length - 1) {}
fs.Read(docByte, 0, System.Convert.ToInt32(fs.Length))
fs.Close()
I do not want the file to open. Any suggestion. Please help me
Regards
Manoj
I'll also suggest that you read the file in inside a Using block and you check to be sure that the file's size isn't too large:
Using fs As New IO.FileStream(filePath, _
IO.FileMode.Open, _
IO.FileAccess.Read)
If fs.Length <= Int32.MaxValue Then
Dim bytes(CInt(fs.Length - 1)) As Byte
fs.Read(bytes, 0, CInt(fs.Length))
' Now do something with the byte array
' just read in. For this example I'll
' just write the file to my desk
Dim desktop As String = _
My.Computer.FileSystem.SpecialDirectories.Desktop
Dim fileName As String = _
IO.Path.GetFileName(filePath)
My.Computer.FileSystem.WriteAllBytes(IO.Path.Combine(desktop, _
fileName), _
bytes, _
False)
Stop
End If
End Using
The test is done because of this: The .Length property of a FileStream is a type Long but the .Length
property of an array is an integer.
Still lost in code, just at a little higher level.

Similar Messages

  • How to write IPTC metadata to files without opening the file?

    HI,
    I'm trying to run a script (preferably in JS) that allows me to write metadata to a file. I can acheive this very easily by opening the file, but I'd need to batch process many large images, so opening them would cause severe slowness. The purpose of adding the metadata to the files is to search upon them in Bridge.
    We're using CS5, but have CS6 if it's better to use.
    My Script
    // set current doc ref
    var docRef = app.activeDocument;
    // Set caption in active document
    docRef.info.caption = "Some Meta-Data";
    Do I need to use bridge to write the metadata without opening the file? Or can running the script in PS allow me to do so?
    Thanks,
    Tom

    Its easy if you use XMP metadata.
    app.activeDocument.info.caption (in photoshop script metadata)
    and it is the same field as:
         Dublin Core namespace
         namespace:     http://purl.org/dc/elements/1.1/
         Property:          description
    you change description on XMP = you are changing the same image.info.caption
    Your answer is here:
    http://forums.adobe.com/message/5743730#5743730

  • How do i download and e-mail from a zip drive without opening the file

    How do I download and e-mail data from a zip drive without opening the file?

    Hi.
    If you have a Zip drive, you can handle the file as you would any other file. Copy and paste.  Drag and drop. Select and attach as an email attachment.
    Zip drive data discs came in two capacities, 100MB and 250MB. So the largest files would not exceed those capacities, depending on the media from which they are pulled.
    The trick, I should think, would be finding a working drive that can read the media... and hope that media is not corrupted. Zip media was notorious for failing.
    I hope this helps.

  • How to open document from mac when using windows without transferring the file?

    How can i open a document from mac when i am using windows without transferring it?

    depend on the document program more then anything else really
    when ever I open a doc with word it make a history for undo and redo action file in the same dir
    with bootcamp you only have read not write access to the osx partition so it would fail to be able to create that file
    but if you can get word or whatever program you use to open the file not to place a temp file in the same dir
    or use a program which did not make any type of temp file or used a program where the temp file would be located elsewhere where you decide it would work file

  • Print without opening the file (using two Adobe versions)

    I used this a lot but recently it's not working.  Right click on the file, hit Print from the drop down and the file magiclly prints. (this magic saves a lot of time)
    Now, when I right click and hit print I get a "Open With" dialog box, forcing me to open the file and then print.
    I have Adobe Acrobat 6.0 Pro and also Adobe Reader 9.1 installed.  I have reader because many websites require 8.0 or higher for pdf browser viewing.  I am guessing the problem is somewhere in the file type association but don't know how to fix it.
    It used to work for me but after some update it's not workinig no more
    Thanks for your help!!!

    If you have a postscript printer or rip which has the ability to create hot folders to link to the printer queues you could simply drag-n-drop and PDL (page description language) file like PDF, PS, EPS to that hot folder to initiate printing. Again, very dependent on your printer/rip device.

  • Printing pdf files in a browser (e.g. Firefox) without opening the file

    I have a web application, which is generating pdf files. Is it possible to print a pdf file on the default printer without opening the pdf file?
    I want to click on the link of a pdf file and the file should be printed immediately on the default printer.

    I do not think this is a feature of the browser. In Firefox I can set that a PDF file is opened using a PDF viewer. At this point I would specify the Adobe reader. Instead of opening the PDF file this file should be printed immediately.
    So my question is: Is it possible to configure the Adobe reader that the PDF file is printed immediately?

  • How to view contents of file without opening the file?

    Does anyone know of a utility that will allow you to quickly view the contents - or a part thereof - of a file (particularly Word files) without having to open the file? I have thousands of files restored after a disk failure, but their filenames have been lost and replaced with sequential numbers. The only way of knowing the contents is to open the file, a tedious process for so many. I seem to recall seeing a shareware app that allowed this. Thanks for any help.
    MacBook Pro 17   Mac OS X (10.4.8)  

    Open the Script Editor in the /Applications/AppleScript/ folder and paste in the following:
    tell application "Finder"
    repeat with this_num from 1 to 5
    set the_item to item this_num of window 1
    set the_name to name of the_item
    set the_text to (read (the_item as alias) from 1 to 15)
    tell application "TextEdit"
    set text of document 1 to (text of document 1) & the_name & return & the_text & return & return
    end tell
    end repeat
    end tell
    Before running the script, place the folder containing the files in the frontmost Finder window; you may want to split the files between several different folders and process each folder before heading on to the next one. The numbers in blue can be customized as needed; the first one controls how many files the script will search on each run, and the other two define what part of the file will be searched. The output from a file which is in a format other than plain text may contain document formatting and other content which will look like random characters.
    (19999)

  • Using ExcelExport without opening the dialog box to select all the channels in portal by default

    Hi,
        I need to export all the data in the Data portal to an Excel file without opening the Dialog for channels selection. In the ExcelExport command, it asks for a Config (*.stp) file as one of the parameters. Is there need to create a new stp file for selecting all channels or can the same file (Example_ASC.stp ) be reused ? If so, do I need to change any content in the system stp file ?
    Thanks
    Venkatesh Murthy

    http://forums.ni.com/ni/board/message?board.id=60&message.id=8565&query.id=128811#M8565

  • Client_ole2 to Print wpw extension file without opening the file

    Hi All,
    I am using oracle 10g and want to print .WPW file directly to Printer without opening it.
    I have used two Procedure
    PROCEDURE Change_attrib(v_filename in varchar2,v_attrib in varchar2) IS
    temp varchar2(200);
    BEGIN
    if v_attrib = '1' then
    temp := 'attrib +R '||v_filename;
    host(temp,NO_SCREEN);
    elsif v_attrib = '0' then
    temp := 'attrib -R '||v_filename;
    host(temp,NO_SCREEN);
    end if;
    END;
    PROCEDURE word_file( p_FileName varchar2 ) is
    args      client_ole2.list_type;
    application client_ole2.obj_type;
    docs      client_ole2.obj_type;
    doc      client_ole2.obj_type;
    Begin
         change_attrib(p_filename,'1');
    application := client_ole2.create_obj('word.application');
         docs := client_ole2.get_obj_property(application, 'Documents');
    args := client_ole2.create_arglist;
    client_ole2.add_arg(args,p_filename);
    doc := client_ole2.invoke_obj(docs,'Open',args);
    client_ole2.invoke(application,'PrintOut');
    client_ole2.destroy_arglist(args);
    client_ole2.release_obj(doc);
    client_ole2.release_obj(docs);
         client_ole2.invoke(application,'Quit');
    End word_file ;
    and Simply call like below
    word_file('c:\cn1.wpw');
    Printing is good but everytime it pop up save as option which is not intended.
    Please Help!!!!!!!!!!!
    Best Regards,
    SPS

    If you have a postscript printer or rip which has the ability to create hot folders to link to the printer queues you could simply drag-n-drop and PDL (page description language) file like PDF, PS, EPS to that hot folder to initiate printing. Again, very dependent on your printer/rip device.

  • Print Attachments Without Opening the File (Right-Click)

    Hello:
    When I right click on any icon attachment to print, I do not see the "print ..." options on the menu.  All I see is "print".  If I select my local printer as default to print,
    I don't have any problems printing, but if I set my network printer as a default, nothing happens.  Nothing appears in the print que as being sent.  The reason I prefer to use the right click method is that I receive many email attachments
    that needs to be printed and opening every attachment is cumbersome.
    Thank you for your help!

    Hi,
    Thank you for your question.
    Which version of Office are you using? I got "Print" too on the menu instead of "Print..." when I right click an attachment icon in the body of an Outlook message. I've checked
    this on Outlook 2007, Outlook 2010 and Outlook 2013, the same display, thus I think, this is the expected behavior.
    Regarding the print issue, does this only happen when you print an attachment from an email message? What if you print an email message or print an Office document directly from the Office applications?
    Please provide more details, so that it will be easy for us to narrow down the issue. As an initial troubleshooting step, you can try to delete that network printer from Control Panel, add it again, then verify result.
    Regards,
    Ethan Hua
    TechNet Community Support
    It's recommended to download and install
    Configuration Analyzer Tool (OffCAT), which is developed by Microsoft Support teams. Once the tool is installed, you can run it at any time to scan for hundreds of known issues in Office
    programs.

  • Actions Possible Without Opening Raw File in Photoshop?

    Is it possible to record certain actions on a raw file without opening the file in Photoshop?
    Let's assume I have 250 files, all needing lens correction (and maybe other common tweaks) as a basic first step.  I'd like to be able to record an action that (1) opens my NEF file in ACR; (2) makes the lens correction based on the profile for the particular lens I used; (3) [other tweak--say noise reduction]; (4) [other tweak--say color temperature]; and then (5) closes the file generating nothing but the .xmp file.
    Then when I go to work on each file, all my basic corrections have been made so that when I reopen later in ACR, I only have to make custom changes before finally opening in Photoshop.
    I've tried a few things, scanned the forums, checked the online help center, gone through a few Adobe TV tutorials, but I can't figure out how to do it.
    Any help?
    I'm in CS6.
    I just realized that this question probably belongs here rather than the ACR discussion.  I apologize for cross posting.

    Phoenix89MR wrote:
    Is it possible to record certain actions on a raw file without opening the file in Photoshop?
    No...an Action is something that records something in Photoshop. Yes, an Action can record ACR settings....but you need to actually end up opening the image in Photoshop and it will render the file.
    What you really want to do is to look into Camera Raw Presets and using them while in Bridge. You would open a representative image, adjust the image, save a preset and then apply that preset to as many images as you want to in Bridge. Also note you can open multiple images in ACR, select them and adjust multple images at once. You can also adjust an image and then in Bridge, copy the settings from the one file and paste them to others.
    Lots of way to accomplish what you want but not really by Actions in Photoshop.

  • After adding still images, FCE crashed and now I cannot open the file

    Anyone know how I can "rescue" my movie? Perhaps some of the images are corrupted but I'm in a Catch 22 since I cannot delete them without opening the file first. My other movies do open, so it appears that overall FCE is working. Hate to lose all this work...

    See if you have an +Auto Save Vault+ file thqty pre-dates the crash.
    Al

  • OneNote recordings "We're sorry, we can't open the file because it is in use by another program."

    Constantly, OneNote breaks and screws up my recordings that are synced with my lectures. It is such a fragile process and very frustrating. As soon as I'm done recording, I press stop. When I test the recording, it says, "We're sorry, we can't open
    the file because it is in use by another program." I just recorded and then stopped it. If i close and reopen OneNote, it says, "oneNote is cleaning up from the last time it was open." And the recording still says it's in use by another program.
    I've even restarted the laptop and it still won't open. The only way i could salvage the file is if I copy and paste it into another folder, and then it will open through windows media player, but all the live syncing with my notes are gone. Where are these
    files stored? If I could save the sound and find the file/format that holds the syncing data again, I could work around this. They are no where to be found on my computer. Other forums give locations, but my folders are empty. Some other recordings work and
    sync nicely, but I have still lost many recordings to this error. However, if I play a file and then close it without stopping playback, that file, too, will now be unusable. It will be stuck as "We're sorry, we can't open..." no matter what i do
    and again i have to copy/paste it into a new folder and then move it back. I had the same problem on my last laptop. I record in Windows Media Audio 10 Professional at 192 kbs, 48 kHz, and stereo CBR. I need the high quality because the lecturer is too quiet.
    It seems to happen when I record long lectures, 45 min+. Shorter recordings tend to work fine.
    Please help, this would make note taking so much easier.

    A bit of a confusion on my part;
    Now we have created these REPORTS using Basic Crystal Report 10.5, which comes bundled with Visual Studio 2008 and .Net Framework 3.0. Now on our machines, we have never experienced any issues.
    Going by the above, you should have references to CR assemblies of version 10.5.3700 only. No other references.
    Now, looking at this paragraph:
    BUT on the DEV server (web server) which has .net Framework 3.0 and in its GAC its has CRYSTAL DLLs version 11.5 (required to create an Object of ReportClass and its related functions) ; sometimes we get the following error while exporting crystal report to pdf:
    I wonder what runtime was deployed to the server. E.g.; if you are using CR 10.5, your assemblies will be 10.5.3700 and you should be deploying the following runtime (depending on 32 bit / 64 bit, etc.):
    CRRedist2008_ia64.msi
    https://smpdl.sap-ag.de/~sapidp/012002523100006255262008E/CRRedist2008_ia64.zip
    CRRedist2008_x64.msi
    https://smpdl.sap-ag.de/~sapidp/012002523100006255272008E/CRRedist2008_x64.zip
    CRRedist2008_x86.msi
    https://smpdl.sap-ag.de/~sapidp/012002523100009351342008E/CRBasicVS2008_redist_x86.zip
    One way to check on what is actually loading is to use the [Modules|https://smpdl.sap-ag.de/~sapidp/012002523100006252802008E/modules.zip] utility.
    - Ludek

  • I have an older version of imovie.  After I change the photos using the Ken Burns effect and save them, the next time I open the file and click 'show photo settings' to change the zoom, the picture appears black and I can't change the zoom?

    I have a five year old version of imovie that generally works fine.  However, when I add a photo using the 'Ken Burns' effect then save the movie, the next time I open the file and click 'show photo settings' the picture appears black and I cannot change the zoom.  Any suggestions?

    Have you rendered both iOS 7 and iOS 8 (both of which will work on your iPhone 5) out of the question entirely without trying every possible configuration? The animations can be disabled entirely, if that's the problem. And if the whiter-brighter user interface is the problem, there's reverse-contrast modes that darken everything. You can expose accessibility controls to gain immediate access to these functions to toggle them on and off. I guess my point is you may have decided against upgrading the OS based on an early experience with iOS 7 when Apple has since made changes in later revisions to address some of the usability complaints.
    Now, Apple's instructions for downloading older versions of apps is to do so from the Purchased list, not from the app's product page.
    See here:
    Install the latest compatible version of an app on an earlier version of iOS or OS X - Apple Support
    Let us know how that works for you.

  • I have PC with Windows XP. I wish to buy a book but it says I need iOS with a specific version of iBooks to open the file. How can I open the product without have a Apple product?

    I have PC with Windows XP. I wish to buy a book but it says I need iOS with a specific version of iBooks to open the file. How can I open the product without using an Apple product?

    What is the GarageBand version that your friend is using?
    If it is GarageBand '11, version 6.0.5, you can buy GarageBand '11 as a boxed retail version with the iLIfe '11 bundle, e.g. from Amazon.
    Then you can upgrade GarageBand '11 to 6.0.5, using this upgrader from the Support page:
                     GarageBand 6.0.5
    GarageBand 6.0.5 will work well with your system.  But if your friend is using the newest GarageBand 10, this will not help. Then ask your friend to send you audio files for each track, so you can recreate the project from the audio.  Or your friend could also use GarageBand '11 for the projects you want to share, that will run well in all newer MacOS X versions, even with GarageBand 10.0 installed on the same system.
    -- Leonie

Maybe you are looking for