.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Help - Merging Two PDF files OR Merging Two Binary files

Posted By:      Posted Date: October 19, 2010    Points: 0   Category :ASP.Net

For some reason the last PDF file to be written to the "final document" is the only PDF File that is visible when the "final document" is open.  However, all of the bytes are accounted for in the file size...so for example: file1 = 60 bytes and file2 = 49 bytes.  The final document has 109 bytes but only contains file2 when viewed in the pdf viewer.  Any ideas?  What am I doing wrong? 


Public Sub getPDFsAndMerge()

        Dim myFinalDocumentPath As String = "C:\Temp\myFinalMergedPDFFile.pdf"
        Dim myFirstDocumentPath As String = "C:\Temp\fileOne.pdf"
        Dim mySecondDocumentPath As String = "C:\Temp\FileTwo.pdf"

        Dim fsFinalStream As New FileStream(myFinalDocumentPath, FileMode.Append, FileAccess.Write)

        Dim fsFirstStream As New FileStream(myFirstDocumentPath, FileMode.Open, FileAccess.Read)
        Dim fsSecondStream As New FileStream(mySecondDocumentPath, FileMode.Open, FileAccess.Read)

        Dim count As Integer = 1024

View Complete Post

More Related Resource Links

Merging Multiple Excel files (exports from Reporting Services)


So we have Office 2007 on our system and I'm trying to use Excel Interop to take a number of Excel files, which are exports from Reporting Services, and combine them into one large workbook.  I'm using the code below which works fine to get all the information from all the files into one workbook but the colors of things goes absolutely haywire.  Anyone know why my colors are getting all out of wack?

protected void MergeFiles(string destinationFile, string[] sourceFiles, string guid)
                //1. Validate folder,  
                //2. Instantiate excel object  
                //3. Loop through the files  
                //4. Add sheets  
                //5. Save and enjoy!  


Web Q&A: Who Called the Script?, Concatenating Binary Files, and More


This month find out which part of an HTML document has called a script, how to concatenate binary files, find a node, reference one script from another, build a GUI database front end in Access, and compare XML files.

Edited by Nancy Michell

MSDN Magazine August 2003

Problem importing text files with binary zeros (0x00) via SSIS(SQL2005). It is all fine when using D

Hi.   There is a "text" file generated by mainframe and it has to be uploaded to SQL Server. I've reproduced the situation with smaller sample. Let the file look like following: A17     123.17  first row          BB29    493.19  second             ZZ3     18947.1 third row is longer And in hex format: 00:  41 31 37 20 20 20 20 20 ? 31 32 33 2E 31 37 20 20  A17     123.17  10:  66 69 72 73 74 20 72 6F ? 77 0D 0A 42 42 32 39 20  first row??BB29 20:  20 00 20 34 39 33 2E 31 ? 39 20 20 73 65 63 6F 6E     493.19  secon30:  64 0D 0A 5A 5A 33 20 20 ? 20 20 20 31 38 39 34 37  d??ZZ3     1894740:  2E 31 20 74 68 69 72 64 ? 20 72 6F 77 00 69 73 20  .1 third row is 50:  6C 6F 6E 67 65 72       ?                          longer          I wrote "text" in quotes because sctrictly it is not pure text file - non-text binary zeros (0x00) happen sometimes instead of spaces (0x20).   The table is: CREATE TABLE eng ( src varchar (512) )   When i upload this file into SQL2000 using DTS or Import wizard, the table contains: select src, substring(src,9,8), len(src) from eng <               src                ><substr>             <len> A17     123.17  first row           123.17                  25BB29                                493.19                  22ZZ3     18947.1 third row           18947.1                 35   As one can see, everything was importe

Missing/Required binary files on one Web-front-end after installed the CU aug 2010 hotfix?

Hi! I have installed the binary files for CU aug 2010 hotfix in a farm with two web-front-ends. In Central Administration you can see that on Web-front-end one (that also is hosting the Central Administration app) the binary files are missing but not on the second Web-Front-End. The installation went fine on both servers with the exception that I had to reboot the Web-Front-end one. When I try to run Psconfig to update my databases I get en error message like this in my command prompt. The upgrade command is invalid or a failure has been encountered. The server farm will not work with missing installs. Add "-cmd installcheck -noi nstallcheck" to the command-line to ignore this warning. The following is missing on web-front-end one: Hotfix for Office (KB2352342) Hotfix for Office (KB2352342) Hotfix for Office (KB2352342) Hotfix for Office (KB2352342) Hotfix for Office (KB2352342) Hotfix for Office (KB2352342) Hotfix for Office (KB2352342) Hotfix for Office (KB2352342) In the event log I get a lot of these errormessages too (EventID 3351): SQL database login for 'SharePoint_Config' on instance 'SqlAliasName' failed. Additional error information from SQL Server is included below. Login failed for user 'Domian\servername (one)$'. The thing is that the files is installed in the filesystems aswell as the dll files in the GAC on both servers. You can´t unistal

Reading large binary files



I currently have a WPF app that controls a printer. The app reads very large binary files (bitmap images, larger than 1 GB) and does some bit manupilation on them.

I am currently using a FileStream to read 100MB worth of bytes into a buffer (using FileStream.Read method). After that I start my method that does the bit manupilation on the image file and sends it out to the interface on a printer. When the buffer nears the end of the 100 MB length, say when there are few 100 bytes left to read in the buffer, I call the FileStream.Read method again to read in the next 100MB worth of data from the binary file. I specify the offset to read the binary file by using FileStream.Position method.

The problem I am facing is that when it finishes reading the 100MB buffer and goes to read the next 100MB worth of data, the printer pauses for the amount of time it takes to read the next 100MB and after that there is a pause for every line it prints in the image. It is like .NET framework or the compiler looses sync of doing things a particular because I have to read the next 100MB and then never recovers. The pause is about 2-3 seconds.

Everything is working great, the bit manipulation is correct, it reads the file correctly, the printer prints the file the way it is supposed to, except I want to avoid the pause.

Any suggestions....Can I use a back

Best way to merge binary files


So I serialized a custom object I have through the BinaryFormatter's serialize method. I am unsure of how exactly it encodes it so I need some information here. I want add some Save/Load functionality so all I need to know is, what the best way to merge these custom files spit out after the Serialize method is done and what would be a good way to split them? I originally was thinking that I could just write to the main file how many files were merged but the thing is, I am not sure what is alright to use to write to these files. I just want to make sure that the files merged and split are exact clones of the way they were before the merge process.


Clean Web.Config Files (VS 2010 and .NET 4.0 Series)

.NET 4 includes a new version of the CLR, and a new .NET 4 specific machine.config file (which is installed side-by-side with the one used by .NET 2, .NET 3 and .NET 3.5).

The new .NET 4 machine.config file now automatically registers all of the ASP.NET tag sections, handlers and modules that we've added over the years, including the functionality for:

.ASP.NET Dynamic Data
.ASP.NET Routing (which can now be used for both ASP.NET WebForms and ASP.NET MVC)
.ASP.NET Chart Control (which now ships built-into ASP.NET V4)
What this means is that when you create a new "Empty ASP.NET application" project in VS 2010, you'll find that the new default application-level web.config file is now clean and simple:

SharePoint document migration challenges when migrating files and folders

There are several challenges when migrating documents to Microsoft SharePoint. While these challenges can be overcome, they are a real pain if the migration source, content and file systems are not SharePoint friendly.

Combine, minify and compress JavaScript files to load ASP.NET pages faster

Websites are getting more interactive these days and most of this interactivity comes from JavaScript. People are using different JavaScript libraries and frameworks to make their websites more interactive and user friendly.

PrintPocketCE Print Pocket Excel, Pocket Word and email files

Version 3.560 (May 15, 2009):

Important bug fix: a slight difference in how some devices create fonts was causing a few devices to have significantly longer print times for large print jobs.

Adjusted PocketJet printer paper feed commands

Other minor fixes and enhancements.

Version 3.559 (Mar 5, 2009):

Added support for Martel MCP78xx printers

Version 3.558 (Aug 20, 2008):

Added support for Martel MCP78xx printers

Version 3.557 (June 27, 2008):

Fixed error in Canon printer support

Fixed COM0 port selection

Version 3.556 (June 15, 2008):

Added support for Brother MW-260

Added support for Sato MB400

Version 3.555 (Aug 8, 2007):

Added support for Pentax RuggedJet 3 and RuggedJet 4 printers

Changed Epson TM-P60 support to maximum page width of 1200 dots

Version 3.551 (Aug 1, 2006):

Added Peripheral Nomad printer support

Version 3.550 (Mar 23, 2006):

Added Panasonic JT-H200PR printer support

Added Pocket Spectrum printer support

Fixed problem with WM5.0 "inverted image" problem

Conversion of text files from ANSI to UTF-8

reading and writing text files in ANSI format and
writing html-files in Charset ISO-8859-1 (Western Europe).

How to transfer files between computer and mobile device using bluetooth

What is Bluetooth? How can I have it on my computer?

Bluetooth wireless technology is a communication technology that allows two devices to communicate wirelessly. Most of the notebooks are nowadays equipped with bluetooth. For those notebooks or computers that don't, you can use a bluetooth dongle to add the functionality and it just costs you around $5. Although higher price range bluetooth dongles are available but it makes no sense of buying them if you just plan to connect your mobile device to the computer. Look for one that has Bluetooth v2.0 + EDR (Enhance Data Rate) supporting speeds of upto 3Mbps and with Vista support. You can easily have one of that kind in just $5.

Setting up bluetooth to work on your computer

Just Insert the bluetooth dongle in the USB.
It should get detected by your Operating System and should be ready to use. In case it is just detected as a new hardware, you need to install drivers for it that came with your bluetooth dongle (You can try Google to find the drivers).
Once drivers are installed, a bluetooth notification icon will appear in your system tray.
Right Click on it to access Settings (This may vary with your bluetooth dongle).
Make sure you have turned Discovery On (It allow others to see your computer).
Switch On the bluetooth on the mobile device.

dynamically adding sql server columns based on number of files in fileuploader


I want to create a new table to sql database at runtime.  The column names would be "Name", "Date", "Event".  I would also like to have one more column name "Image" but the problem is that since the amount of images will vary, I want the application to count the amount of files in the Multiple fileuploader and then add a image column to the table for the respected amount of files. 

For example if i am uploading 3 files in the multiple fileuploader, the names should be "Name", "Date", "Event", "Image1", "image2", Image3"

I also would like that table name to be name dynamically from the textbox Name when the user enters the information.


I have the following code to make a new table, but I dont know how to name the fields at runtime like previously asked please help!!!


Dim objConn As New SqlConnection("Server=<servername>;uid=<userid>;pwd=<password>;database=master")


Printing resource files



I have some resource files for localization and would like to print them. When I try to print them in Visual Studio (with File -> Print...) the button is disabled. Does anyone know how to print them? (Without copying each into word or excel)

Thanks and regards,

Wrong Account being used to access files - Help - No Impersonation


I run a simple .aspx website on a Windows Server 2008 machine.

There is NO impersonation, and System.Security.Principal.WindowsIdentity.GetCurrent().Name returns NT AUTHORITY\NETWORK SERVICE, which it the account which the application pool runs. In my web.config, I have <authentication mode="Forms">.


I tried to test the security of the application and server by removing file permissions to the .aspx files. I was greatly worried when the website continued to run without problem (it should not have been able to read the .aspx files).

By turning on file level auditing, I discovered that the .aspx files were being read by the machine$ account (if the machine is called Serv1, then the files would be read by the Serv1$ account, which seems to have access to all files on the local machine).


Is this a security breach or is this behaviour by design ?

Please can somebody assist, as I am worried.

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend