|
I'm not sure what you're after, but using Rows method you can select an entire row. For example:
Application.ActiveSheet.Rows("1:1").Select
After that you can iterate through the Range object using Application.Selection .
Hopefully this gets you forward.
The need to optimize rises from a bad design.
My articles[ ^]
|
|
|
|
|
I have a process whereas I need to save a string from a textbox to a temp file and then hashing the file via SHA1. I have that handled but when I create the file and write the data to the file
"08 39 01 62 30 21 12 69 09"
it is written in ascii and I need it written in hex as is. So if you opened the file up in a hex editor you would see "08 39 01 62 30 21 12 69 09" with the ascii as .9.b0!.i. .
Currently I am only getting 30382033392030312036322033302032312031322036392030390D0A
as my hex string in the hex editor and obviously hashing that value will not match the hash of h08 h39 h01 h62 h30 h21 h12 h69 h09
Thanks for any and all help.
Celldet
|
|
|
|
|
A quick look at an ASCII table reveals that you have "08 39..." as a string variable. So of course when you write the string to the file, you get the string in the file. If you want to store the bytes represented by the string, you will need to parse it yourself. I would start with String.Split and Byte.Parse with a parameter of System.Globalization.NumberStyles.AllowHexSpecifier and a BinaryWriter.
|
|
|
|
|
Worked out great!!!! Thanks for the pointing to the right direction.
|
|
|
|
|
Hi,
can anyone help me to compress and decompress a text file(.txt) using VB.NET.
I tried but i got error msg as "Magic number in GZip header is INCORRECT".
|
|
|
|
|
thiru_5862 wrote: can anyone help me to compress and decompress a text file(.txt) using VB.NET.
I tried but i got error msg as "Magic number in GZip header is INCORRECT".
You tried with what code??
|
|
|
|
|
Hi Dave.. The code which i use to decompress the file is given below.. Am getting the error "Magic number in GZip header is INCORRECT".
dim source_file as string = "c:/Compressed.txt"
dim destination_file as string = "c:/Decompressed.txt"
Dim sourceFile As FileStream = File.OpenRead(source_file)
Dim destinationFile As FileStream = File.Create(destination_file)
destinationFile.Close()
Dim ms As New MemoryStream()
Dim zipStream As New DeflateStream(ms, CompressionMode.Decompress)
Dim decompressedBuffer(3500) As Byte
System.IO.File.WriteAllBytes(destination_file, decompressedBuffer)
'end writing
'Because the uncompressed size of the file is unknown,
'we are imports an arbitrary buffer size.
Dim buffer(4096) As Byte
Dim n As Integer
Using input As New GZipStream(source_file, _
CompressionMode.Decompress, False)
Console.WriteLine("Decompressing {0} to {1}.", source_file.Name, _
destination_file.Name)
n = input.Read(decompressedBuffer, 0, decompressedBuffer.Length)
destination_file.Write(decompressedBuffer, 0, n)
End Using
'Close the files.
source_file.Close()
destination_file.Close()
|
|
|
|
|
|
Sorry Dave.. I gave the old code .. Below u can find the latest code i use. In the below code.. am getting the exception(Magic number in GZip header is INCORRECT) in line
n = input.Read(decompressedBuffer, 0, decompressedBuffer.Length)
'Compressed File path
dim comp_file as string = "c:/compressed.txt"
'File to which decompressed contents has to be written
dim dest_file as string ="c:/decompressed.txt"
Dim sourceFile As FileStream = File.OpenRead(comp_file)
Dim destinationFile As FileStream = File.Create(dest_file)
destinationFile.Close()
Dim ms As New MemoryStream()
Dim zipStream As New DeflateStream(ms, CompressionMode.Decompress)
Dim decompressedBuffer(3500) As Byte
System.IO.File.WriteAllBytes(dest_file, decompressedBuffer)
'end writing
'Because the uncompressed size of the file is unknown,
'we are imports an arbitrary buffer size.
Dim buffer(4096) As Byte
Dim n As Integer
Using input As New GZipStream(sourceFile, _
CompressionMode.Decompress, False)
Console.WriteLine("Decompressing {0} to {1}.", sourceFile.Name,_
destinationFile.Name)
n = input.Read(decompressedBuffer, 0, decompressedBuffer.Length)
destinationFile.Write(decompressedBuffer, 0, n)
End Using
'Close the files.
sourceFile.Close()
destinationFile.Close()
|
|
|
|
|
This is a bit of spaghetti code, it's a little hard to follow. But, from what I can tell, you're trying to decompress a normal text file, which won't work and would explain the error you're getting. We can't really tell because we don't know the contents of "C:\compressed.txt". Also, forward slashes, in Windows, are used to denote command line paramters, not file paths. I suggest getting into the habit of specifying filepath with backslash's, "\".
|
|
|
|
|
Hi.. thanks for suggesstions.. can u suggest any code that i can use to compress and decompress a text file.
|
|
|
|
|
I dont' have any and don't have the time right now to create an example.
You've got the basic building blocks. You just need to examine your code, and especially the documentation on the zip stream classes, and lay out what you need to do, step-by-step. Just work on compressing a text file to another file first. Once that's done, then you can worry about uncompressing it.
|
|
|
|
|
Dave Kreskowiak wrote: bit of spaghetti
Would you like some Parmesan cheese with that, sir?
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
To better help you, provide a sample of the code you are using.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
Hi Paul.. The code which i use to decompress the file is given below..
dim source_file as string = "c:/Compressed.txt"
dim destination_file as string = "c:/Decompressed.txt"
Dim sourceFile As FileStream = File.OpenRead(source_file)
Dim destinationFile As FileStream = File.Create(destination_file)
destinationFile.Close()
Dim ms As New MemoryStream()
Dim zipStream As New DeflateStream(ms, CompressionMode.Decompress)
Dim decompressedBuffer(3500) As Byte
System.IO.File.WriteAllBytes(destination_file, decompressedBuffer)
'end writing
'Because the uncompressed size of the file is unknown,
'we are imports an arbitrary buffer size.
Dim buffer(4096) As Byte
Dim n As Integer
Using input As New GZipStream(source_file, _
CompressionMode.Decompress, False)
Console.WriteLine("Decompressing {0} to {1}.", source_file.Name, _
destination_file.Name)
n = input.Read(decompressedBuffer, 0, decompressedBuffer.Length)
destination_file.Write(decompressedBuffer, 0, n)
End Using
'Close the files.
source_file.Close()
destination_file.Close()
|
|
|
|
|
source_file should be sourceFile . You cannot have a string where it is requiring a stream. Same thing applies to destination_file and destinationFile . These are not the cause for your exception, but are a cause for your code not to compile.
You might want to have the following:
source_file.Close()
destination_file.Close()
prior to your attempt at decompressing the file and outputting. This will ensure the buffer is getting flushed and the test compressed file has all of its data written.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
Sorry Paul.. I gave the old code .. Below u can find the latest code i used.
In the below.. am getting the exception in line
"n = input.Read(decompressedBuffer, 0, decompressedBuffer.Length)"
'Compressed File path
dim comp_file as string = "c:/compressed.txt"
'File to which decompressed contents has to be written
dim dest_file as string ="c:/decompressed.txt"
Dim sourceFile As FileStream = File.OpenRead(comp_file)
Dim destinationFile As FileStream = File.Create(dest_file)
destinationFile.Close()
Dim ms As New MemoryStream()
Dim zipStream As New DeflateStream(ms, CompressionMode.Decompress)
Dim decompressedBuffer(3500) As Byte
System.IO.File.WriteAllBytes(dest_file, decompressedBuffer)
'end writing
'Because the uncompressed size of the file is unknown,
'we are imports an arbitrary buffer size.
Dim buffer(4096) As Byte
Dim n As Integer
Using input As New GZipStream(sourceFile, _
CompressionMode.Decompress, False)
Console.WriteLine("Decompressing {0} to {1}.", sourceFile.Name,_
destinationFile.Name)
n = input.Read(decompressedBuffer, 0, decompressedBuffer.Length)
destinationFile.Write(decompressedBuffer, 0, n)
End Using
'Close the files.
sourceFile.Close()
destinationFile.Close()
|
|
|
|
|
Dear All,
Iam new to c# window application and also for COM.I have a COM component
which is developed in Visual Basic.Now i want to use this component into
my c# window application.How can i register and use.The COM is in the form
of EXE not in the form of DLL.Please help me out on this.
Thanks & Regards
Veeresh
i want to join this group
|
|
|
|
|
Hi,
The SyncFusion technology can help you please search for that.
Thanks a Lot,
Aleem Mohammad
Thanks & Regards,
Md. Abdul Aleem
NIIT technologies
|
|
|
|
|
RegSvr32 is used to register COM components, but it your case, it may not work. If this is an .EXE COM server, then the ojects it exposes may not be available at all until your start that .EXE. You won't be able to set a reference to that servers exposed classes, so you might end up using late-binding to get at them. This is not a preferrable situation for someone who is only starting out in C# or VB.NET.
BTW, you asked a question about C# in a VB.NET forum...
|
|
|
|
|
veereshIndia wrote: Now i want to use this component into
my c# window application
You'd be better off asking in the C# forum.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
he'd be better off not asking it in FOUR forums though.
Blog link to be reinstated at a later date.
|
|
|
|
|
It would be nice if there was a ban function to punish people who do so. Whether the ban is temp or perm is a toss up, but the penalty factor would be nice.
Any suggestions, ideas, or 'constructive criticism' are always welcome.
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
|
|
|
|
|
Yep. His question should generally be in either the C# forum, or .NET Framework forum. Pick JUST one, not loads of them. It cannot really be that hard.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
Hi,
If he asks again in any other forum it becomes like duplicate one, either it is C# or VB.Net converting a COM component process is same, instead of asking him to post in another forum, we can just understand his problem and answer him with good answer.
Isnt it a good Idea?
Thanks,
Aleem Mohammad.
Thanks & Regards,
Md. Abdul Aleem
NIIT technologies
|
|
|
|
|