|
Hi All
Can anyone suggest me an idea for reading .dxf file
Regards
Gany
|
|
|
|
|
DXF file is as per the following http://en.wikipedia.org/wiki/AutoCAD_DXF[^]
You will either need to find a free viewer or library to use these files...or if you have a lot of time to spare, write your own.
|
|
|
|
|
Hi all...
I want to create a simple program which takes a file and compute its hash value, also it will check whether the file is corrupt or damaged or not.
I googled a lot but I did not get any code for that error detection.
If you have any piece of code then suggest me..
Thanks.
Gagan
|
|
|
|
|
If you generate a hash value when the file is generated. and then re-check the hash at a later date, you will know that the file is still the same and not-corrupted if the hash value doesn't change.
Do a search for MD5, SHA1, SHA256 etc.
|
|
|
|
|
Hi,
I have some high-performance C# code that reads any file and calculates a CRC32 for it; it is table-driven to get maximum speed. There is an infinite number of definitions for checksums, hashes and the like, however my code returns the same value that is reported by ZIP utilities such as WinZip.
If you're inexperienced in bit fiddling, you may have some trouble in translating it to another language, especially VB/VB.NET; not sure the automatic translators such as this one[^] would do a good job here.
Interested?
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. [The QA section does it automatically now, I hope we soon get it on regular forums as well]
|
|
|
|
|
Thanks for your reply,,,
Could you gimmie some piece of code in C#. Is it possible to judge whether the file is damaged or not by computed hash value??
Thanks.
Gagan
|
|
|
|
|
to check for "damage" you need to:
1. have a file
2. calculate some kind of checksum
3. wait
4. calculate the checksum again in an identical way
5. if the results of (2) and (4) don't match, you can be sure the file was modified during (3); if they match, that most likely means the file was not modified.
FWIW: If, between (2) and (4) the file gets transfered to another machine, so (4) is not running where (2) was running, then you also need to transfer the checksum somehow; someone intending to fiddle with your file could also do so to whatever you choose for transferring the checksum
The code I have only calculates the checksum, it does not check anything, nor does it have a GUI.
It has two methods, the first is simply reading all the data reusing the same buffer over and over
(pseudocode shown), the second is "adding" the data to the ongoing CRC.
private static uint[] CRCtable={
0x00000000, 0x1db71064, 0x3b6e20c8, 0x26d930ac,
0x76dc4190, 0x6b6b51f4, 0x4db26158, 0x5005713c,
0xedb88320, 0xf00f9344, 0xd6d6a3e8, 0xcb61b38c,
0x9b64c2b0, 0x86d3d2d4, 0xa00ae278, 0xbdbdf21c};
public static uint CalcCRC(string fileName) {
uint CRC=0;
open the file
byte[] buf=new byte[0x10000];
for(;;) {
int count=readBinaryDataFromFileReturningCount(file, buf);
if (count<=0) break;
CRC=updateCRC(CRC,buf,count);
}
close the file
return CRC;
}
private static uint updateCRC(uint CRC, byte[] buf, int count) {
CRC=~CRC;
for (int i=0; i< count; i++) {
byte chr=buf[i];
uint index=(CRC^chr)&0x0F;
CRC=(CRC>>4)^CRCtable[index];
chr>>=4;
index=(CRC^chr)&0x0F;
CRC=(CRC>>4)^CRCtable[index];
}
return ~CRC;
}
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. [The QA section does it automatically now, I hope we soon get it on regular forums as well]
modified on Friday, January 22, 2010 12:44 PM
|
|
|
|
|
Are you sure a file will have two different hash values after sometime if it is damaged or corrupted??
|
|
|
|
|
No.
I said "if the results of (2) and (4) don't match, you can be sure the file was modified during (3); if they match, that most likely means the file was not modified." and nothing else.
There isn't a checksum, hash or anything in the world that will assure this.
The larger the checksum range (i.e. the more bits it uses), the lower the probability of a false match.
If you need to be absolutely sure, you need a check that has at least the same number of bits as the [ADDED] optimal loss-less compressed version of [/ADDED] the actual file itself.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. [The QA section does it automatically now, I hope we soon get it on regular forums as well]
modified on Friday, January 22, 2010 12:56 PM
|
|
|
|
|
dear all
i would like to lock keyboard and mouse when my system is running by vb6, however i got some code here, but when i run, some error is there, any one can help me, urgent, thanks.
Option Explicit
Declare Function SetWindowsHookEx Lib "user32" Alias "SetWindowsHookExA" (ByVal idHook As Long, ByVal lpfn As Long, ByVal hmod As Long, ByVal dwThreadId As Long) As Long
Declare Function UnhookWindowsHookEx Lib "user32" (ByVal hHook As Long) As Long
Declare Function CallNextHookEx Lib "user32" (ByVal hHook As Long, ByVal ncode As Long, ByVal wParam As Long, lParam As Any) As Long
Public hnexthookproc As Long
'Public Const HC_ACTION = 0
'Public Const WH_KEYBOARD = 2
Public Sub UnHookKBD()
If hnexthookproc <> 0 Then
UnhookWindowsHookEx hnexthookpro
hnexthookproc = 0
End If
End Sub
Public Function EnableKBDHook()
If hnexthookproc <> 0 Then
Exit Function
End If
hnexthookproc = SetWindowsHookEx(2, AddressOf MyKBHFunc, App.hInstance, 0)
If hnexthookproc <> 0 Then
EnableKBDHook = hnexthookproc
End If
End Function
Private Sub Command1_Click()
EnableKBDHook
End Sub
Private Sub Command2_Click()
UnHookKBD
End Sub
Public Function MyKBHFunc(ByVal iCode As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
MyKBHFunc = 0
If iCode < 0 Then
MyKBHFunc = CallNextHookEx(hnexthookproc, iCode, wParam, lParam)
Exit Function
End If
If wParam = vbKeyReturn Then
Debug.Print "haha"
Else
Call CallNextHookEx(hnexthookproc, iCode, wParam, lParam)
End If
End Function
Private Sub Form_Load()
EnableKBDHook
End Sub
Private Sub Form_Unload(Cancel As Integer)
CallUnHookKBD
End Sub
the problem is underline point.
|
|
|
|
|
Does the function reside in a DLL?
I are Troll
|
|
|
|
|
Can someone tell me why I would receive the following incode error: "
Expression is a value and therefore cannot be the target of an assignment"
Dim i, j As Integer
Dim xlapp As Excel.Application
Dim xlsht As Excel.Worksheet
Dim rng As Excel.Range
xlapp = New Excel._ExcelApplication
xlapp.DisplayAlerts = False
xlapp.Workbooks.Add()
xlsht = CType(xlapp.Sheets(1), Excel.Worksheet)
xlsht.Name = "BDIS Data Download"
Dim dc As DataColumn
Dim dr As DataRow
For i = 0 To gridContract.Columns.Count - 1
xlsht.Cells(1, i + 1) = gridContract(i).ColumnName
rng = CType(xlsht.Cells(1, i + 1), Excel.Range)
rng.Font.Bold = True
Next
For i = 0 To gridContract.rows.count - 1
For j = 0 To gridContract.Columns - 1
xlsht.Cells(i + 2, j + 1) = gridContract.rows(i)(j)
Next
Next
|
|
|
|
|
xlsht.Cells(1, i + 1) set a range object. you cannot assign it a value by using =
To set the range, the value you are trying to set, must be within the (...)
|
|
|
|
|
Simple. xlsht.Cells(...) returns a Range object, not a Value property.
|
|
|
|
|
Can't you just change
xlsht.Cells(1, i + 1) = gridContract(i).ColumnName
to
xlsht.Cells(1, i + 1).Value = gridContract(i).ColumnName
?
|
|
|
|
|
Thank you. I did make this correction.
|
|
|
|
|
SEND IT ON MY MAIL ID pollinedsac@gmail.com
|
|
|
|
|
|
rahuldsac wrote: WHERE WILL I GET VB.NET PROJECT
The magic fairies at the bottom of your garden, perhaps.
rahuldsac wrote: SEND IT ON MY MAIL ID pollinedsac@gmail.com
No, you did not use the magic word !!!
Steve Jowett
-------------------------
Real programmers don't comment their code. If it was hard to write, it should be hard to read.
|
|
|
|
|
YOU HAVE TO GO TO THE TOP OF A VERY TALL BUILDING THEN JUMP OFF IT, THE RESULTANT SPEED WILL OPEN A PORTAL TO ANOTHER WORLD WHERE YOUR PROJECT IS WAITING FOR YOU
|
|
|
|
|
Lolz.......
|
|
|
|
|
Guess what?! You got a fever, and the only prescription... is more cowbell VB Projects!
|
|
|
|
|
Hi rahuldsac.
Bad news: Nobody's able to send VB.NET project to you, but the good news is, CERN called justed a moment ago: they discovered a new elementary particle and they want to name it after you: the Moron.
"A moron is a special kind of elementary particle. The moron is classified as massless and with a spin of "dizzying". Morons are thought to normally travel at the speed of light, though it is possible to render them inert and motionless by passing then near cold beer. In String Theory, Morons are believed to be composed of Dubliner cheese and are believed to be the messenger particle, which represents unity (one unit) of the weak force Stupid."
|
|
|
|
|
Hi every one...
I have a Windows Form Application in VB.Net... in this Windows Form I have a textBox... with a "validate" button...
I need that when I input a user ID in the text box, the application go to the access and user table to see if the user is admin... if true print user name is admin else prints user name is not admin
the 2 tables design
tblUser (IDUser, UserName, FullName)
tblAcess (IDUser, AccessLevel [that can be admin or user] )
I just try to do it, but I receaved a message that the datareader is allready open and I cannot open other datareader.... see my code please:
<br />
Private Sub txtCardNum_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtCardNum.KeyPress<br />
If Char.IsNumber(e.KeyChar) Or e.KeyChar = Chr(13) Or e.KeyChar = Chr(8) Then<br />
e.Handled = False<br />
If e.KeyChar = Chr(13) Then<br />
If txtCardNum.Text = "" Then<br />
MsgBox("User ID can not be empty")<br />
Else<br />
Dim CardNum As String = txtCardNum.Text<br />
<br />
Dim SQL As String<br />
SQL = "SELECT U.CodUser, U.FullName FROM tblUser U INNER JOIN tblAccess A ON U.CodUser = A.CodUser WHERE A.AccessLevel = 'Admin' AND A.CodUser = @CodUser"<br />
Dim myCommand = New SqlCommand(SQL, myConnection)<br />
myCommand.Parameters.Add("@CodUser", SqlDbType.VarChar).Value = CardNum<br />
<br />
Dim SQL2 As String<br />
SQL2 = "SELECT CodUser, FullName FROM tblUser WHERE CodUser = @CodUser"<br />
Dim myCommand2 = New SqlCommand(SQL2, myConnection)<br />
myCommand2.Parameters.Add("@CodUser", SqlDbType.VarChar).Value = CardNum<br />
<br />
Dim reader As SqlDataReader = myCommand.ExecuteReader()<br />
Dim reader2 As SqlDataReader = myCommand2.ExecuteReader()<br />
'Caso existam linhas<br />
If reader.HasRows Then<br />
While reader.Read()<br />
lblFullName.Text = reader(1)<br />
lblLevel.Text = "Admin" <br />
txtCardNum.Text = "" <br />
End While<br />
reader.Close()<br />
Else<br />
Dim reader2 As SqlDataReader = myCommand2.ExecuteReader()<br />
lblNomeCliente.Text = reader2(1)<br />
lblLevel.Text = "Normal User"<br />
txtCardNum.Text = ""<br />
reader2.Close()<br />
End If<br />
End If<br />
End If<br />
Else<br />
e.Handled = True<br />
End If<br />
<br />
End Sub<br />
<br />
but when I try to execute and do the query I receave a error: "the data reader is allready open"
how can I solve it?
thanks
regards
PS
|
|
|
|
|
This was a pretty obvious error. You already open two readers, then you try and execute the second reader again. You have this line in your code twice:
Dim reader2 As SqlDataReader = myCommand2.ExecuteReader()
Remove the second occurance and you should be fine.
|
|
|
|
|