|
This has got so many problems I don't know where to start.
First, you've got an XML file that holds all the position data in the archive, but you've got nothing persisting this XML data anywhere. Once you're app is closed, it's gone and you have no hope of decrypting the data in the archive, let alone finding it.
You've got no code at all that removes a file from the archive, nor anything that updates pointers to where the remaining files would now be in the modified archive. You've got nothing to add files, nothing to manage the collection of files and the data, no real data structures tracking this stuff, ... basically, this was done entirely wrong. From what I can see in this code, you've got no hope of fixing this because it has to be completely torn down and a new library created that just handles these custom archive files. Forget the form stuff and getting values from TextBox's. The library shouldn't care at all about TextBox's. It should only get it's data from parameters passed into well crafted methods, such as (an overly simplified list!) AddFile(filepath), DeleteFile(filepath), CreateNewArchive(archivePath), ...
|
|
|
|
|
I don't think I need persists when the application isn't going to be web based. I mean it decrypts fine but my problem is deleting the file from the secure file. I understand about the data Structure but this is a application is form based and I have to do it this way. If it was for me, I prolly would use vb to do this.
|
|
|
|
|
No one said anything about this being web-based.
What you have simply isn't going to work - period, end of story. You have nothing managing the format of the file at all, maintaining the indexes where the start of every file is in the archive, which is a non-optional requirement for functionality like this.
|
|
|
|
|
What will be used to manage the xml? An object? make it object orientated.
|
|
|
|
|
That's where your data structures come in. You can create your own class that tracks this information and is serializable.
In my humble opinion, Version 1 of my file format would lay out like this:
preamble bytes (signature)
64-bit integer offset of file table
encrypted file1 bytes
encrypted file2 bytes
encrypted file3 bytes
encrypted file4 bytes
encrypted file5 bytes
.
.
.
file table data
By putting the file table data at the end of the file, you make it easier to add and remove files from the archive as every time you close the archive, you have to write the file table to the end of the file, at a easily obtainable offset. Once that is written, you can update the fixed length 64-bit integer offset with the beginning of the file table.
Like I said, this would be my version 1 layout. Version 2 would probably add a file header to each file with checksum and length data and maybe a second copy of the file table data for backup purposes. You could even write a tool to recover salvagable files from a corrupted archive if you so choose.
Why WOULDN'T I do this? Because if the archive gets damaged, your archive isn't supported by ANY recovery and analysis tools used on other well-known file formats, unless you write these tools yourself.
|
|
|
|
|
So the file data table will be part of the file and not a external source like the xml? So when I need something out the file, I can pull this and check it and than extract the information.
|
|
|
|
|
Yep. Everything in one file and you can easily Seek to anywhere in the file any read/write any number of bytes, so long as you know the file format.
The only problem with a solution like this is when doing file operations in the archive, the easiest implementation maintains the entire file table in memory for the life of the set of operations and gets written out only when the archive is closed. If the machine loses power during this time, you've just corrupted the archive file.
|
|
|
|
|
Private Sub CreateDataTable()
'Creates a better way for securing data'
Dim parent As DataTable = New DataTable("ParentTable")
Dim column As DataColumn = New DataColumn
column.DataType = System.Type.GetType("System.String")
column.ColumnName = "FileName"
column.Unique = True
column.ReadOnly = False
parent.Columns.Add(column)
'Creating a second column'
column = New DataColumn()
column.DataType = System.Type.GetType("System.Byte")
column.ColumnName = "Size of File"
column.Unique = False
column.ReadOnly = True
parent.Columns.Add(column)
'Creating columns for storing data positions'
column = New DataColumn
column.DataType = System.Type.GetType("System.String")
column.ColumnName = "File starting Location"
column.Unique = True
column.ReadOnly = True
parent.Columns.Add(column)
End Sub
|
|
|
|
|
You shouldn't be using a DataTable for this. It's too heavy an object to serialize into your achive file. Create a structure that hold this information, then create a generic collection to hold instances of this structure. For example:
<Serializable> _
Public Structure FileRecord
Public FileName As String
Public PositionOffset As Long
Public EncryptedLength As Long
Public OriginalLength As Long
End Structure
These would be held in a collection declared like this:
Dim fileRecords As New List(Of FileRecord)
.
.
.
Dim newFile As FileRecord
newFile.FileName = "blahh.bla"
newFile.PositionOffset = whateverOffset
newFile.EncryptedLength = whateverByteLength
newFile.OriginalLength = whateverOriginalFileWas
fileRecords.Add( newFile )
|
|
|
|
|
Ok I'll do that.
Which do you think is better? FileStream or BinaryWriter & BinaryReader? When I'm using FileStream the file doesn't go past 194,000KB and it doesn't get any larger.
|
|
|
|
|
Dave,
Its been a while since I've programmed in vb but I'm going to implement a data table and post it on here to see if I'm going in the correct direction.
|
|
|
|
|
If you're talking about keeping users from deleting the archive file, the only way to do that would be to protect the file and it's parent folder with appropriate NTFS permissions.
|
|
|
|
|
I concur with Dave.
I would like to add I don't like encryption or packaging schemes that result in two files; IMO the net result should be a single file, avoiding all possible catastrophes when one file is lost, or the two files don't match together.
What reasons do you have not to use a popular format (ZIP, TAR, ...) and the existing tools or libraries?
|
|
|
|
|
When I asked what was going on, I was about to pull my hair out but after taking a break and coming back I see everything you two are saying. However, this application depends heavily on two forms, its not a web based application, it can't have a database, using .net framework 2.0 so I'm was very . First Sorry Dave and company for going off. But I really do need some help and would like to build this program as professionally as possible. However, I can't get rid of the forms. Would you people help me out? I see what you mean by pointers but I can't use zip. I distributed it to my customer before and he rejected it because I had to delete the file and he wants it so the OS can't read it. I have the algorithm to do the work but after finding out that he wants 5GB files and very small files. This application will not work for that. I'm going to start this application all over and the file safe.fva is where the file will encrypted and stored. Central location... any help at this time with this will be good.
|
|
|
|
|
OK, this requires that you maintain a filesystem inside a file, which REQUIRES maintaining all this data so that you can perform these file operations and rewrite the archive file as appropriate. You simply have no choice here. What you have isn't going to do the job for you at all. It needs a much more complex solution, which we've already explained.
|
|
|
|
|
Ok... I do need to encrypt this is required. I hate that its required but it needs to be done.
|
|
|
|
|
Why does the doesn't go any further than 194,000 kb?
|
|
|
|
|
I have no idea what you're talking about...
|
|
|
|
|
Hi, I tried do use an typed DataSet (with 2 Tables, 1 Master-detail-Relation),
and wrote:
DataGridView1.DataSource = DataSet1
the Gridview shows the columns well, but null data, null rows.
A Method like DataSet1.Fill I missing, you can me help, how the Data load in the DataSet?
Many thanks, Jan.
|
|
|
|
|
Since your DataSet1 contains 2 Tables, you'll have to set the table you'll want to show.
So use:
DataGridView1.DataSource = DataSet1.Tables("TableName")
|
|
|
|
|
it dosn´t work. may be, the relation between master and detail not is correct?
Im using mysqlconnector 5.1 and made the dataset in vs2008-datenquellen.
the datas are in the dataset - with xml i can all export.
but in the grid nothing to see.....
please help ......
|
|
|
|
|
What do you mean by "It doesn't work"?? What DOES happen? What does the code look like that you're using to set the datasource?
You can use an index number in the DataSet.Tables(index), instead of a string. Have you tried that??
|
|
|
|
|
Fill method belongs to DataAdapter type, not DataSet. Probably your GridView is empty becouse your DataSet is empty. See DataAdapter documentation.
|
|
|
|
|
Hi Erik, it is me clearly.
DataAdapter has filled the tables in the dataset, i Can export to xml. More then 2000 rows.
DataGridView shows the data still does not, data source and data member are set, the DataSource= DataSet1,
DataMember = tableName. Does it need more settings so the GridView works and shows the data?
It shows the ColumnNames, but ZERO Data.
Thanks for help.
|
|
|
|
|
Hi
When I try to set the particular rows height, it has not changed the height...So I cant identify my mistake...Any Help Please...
My Code..
DataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill
DataGridView1.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.None
DataGridView1.AllowUserToResizeRows = False
DataGridView1.Rows(2).Height = 75
Thanks for the guidences...
Thanks By
PARAMU
|
|
|
|