Posts

Showing posts with the label Files

Debug VBScript / VBS files in Visual Studio 2010

Image
I needed to be able to step through a VBScript file that was being run in an environment that I did not have on my machine and this environment did not have a debug environment that I could use to step through the VBScript being executed.  The VBScript was simply looking to see if a folder exists on a network drive and if the folder did exist, create the folder.   Then the script would copy some files to the network drive / folder location.  My machine and user id had access to this network drive so I could run this VBScript from my machine. So placed the VBScript file (script.vbs) on my computer at C:\Projects\VBS\. Then I ran the Visual Studio 2010 Command Prompt as Admin and changed the directory to the above location: I then typed in the following and selected the enter key to run the Visual Studio Just-In-Time Debugger: cscript /x /d script.vbs The following will be presented: Be sure you select the "New instance of Microsoft Visual Studio 2010" and s...

http Downloading Files and Browser Issues

While working on a project, I needed to download a document from the database and stream it to the client.  Our standard browser was IE 7+ and the standard code implementation documented throughout many forums the following with the first line simply obtaining the file via a service:   byte[] fileContents = csc.GetFileContent(this.CurrentContentId); Response.ClearContent(); Response.ContentType = this.ContentType; Response.AddHeader("content-disposition", string.Format("attachment;        filename={0}", this.ContentFileName)); Response.AddHeader("content-length", fileContents.Length.ToString()); Response.BinaryWrite(fileContents); Response.Flush(); Response.End();  The " Response.End() " at the end will cause a ThreadAbort exception within IE and other browsers.  The solution to this was to wrap this code inside a try-catch block and absorb the ThreadAbortException as follows: try  {    ...