Results 1 to 8 of 8

Thread: Temp Files Everywhere!!!!

  1. #1

    Thread Starter
    Fanatic Member cid's Avatar
    Join Date
    Nov 2002
    Location
    Fort Worth, Texas
    Posts
    854

    Temp Files Everywhere!!!!

    My program creates temp files...Which is ok...Until you have over 400 of them on your hardrive. My program uses encryption to encrypt and decrypt passwords in an *.ini file.
    I didnt create this encryption or decryption code so I wouldnt know how it works.
    Does the code below cause the creation of hundreds of *.ini files?

    Encrypt Code:
    VB Code:
    1. Private Sub cmdencrypt_Click()
    2. On Error GoTo handler2
    3. cmdencrypt.Enabled = False
    4. cmddecrypt.Enabled = False
    5. cmdexit.Enabled = False
    6. Dim full, full2, temp, lin As String
    7. temp = ""
    8. If txtname.Text = "" Then
    9.   cmdencrypt.Enabled = True
    10.   cmddecrypt.Enabled = True
    11.   cmdexit.Enabled = True
    12.   Exit Sub
    13. End If
    14. If (UCase(Right(txtname.Text, 3)) <> "TXT") And (UCase(Right(txtname.Text, 3)) <> "INI") And (UCase(Right(txtname.Text, 3)) <> "VBS") And (UCase(Right(txtname.Text, 3)) <> "INF") And (UCase(Right(txtname.Text, 3)) <> "BAT") Then
    15.   cmdencrypt.Enabled = True
    16.   cmddecrypt.Enabled = True
    17.   cmdexit.Enabled = True
    18.   Exit Sub
    19. End If
    20.  
    21. If Right(Dir1.Path, 1) = "\" Then
    22.    full = txtname.Text
    23. full2 = App.Path & "\temp.tmp"
    24. Else
    25.   full = txtname.Text
    26. full2 = App.Path & "\temp.tmp"
    27. End If
    28. Open full For Input As #3
    29. Line Input #3, emp
    30. Close #3
    31. If emp = "" Then
    32.   cmdencrypt.Enabled = True
    33.   cmddecrypt.Enabled = True
    34.   cmdexit.Enabled = True
    35.   Exit Sub
    36. End If
    37. chksum = "[§Encrypted§]"
    38.  
    39. Open full For Input As #1
    40. Line Input #1, chks
    41. Close #1
    42. If (chks = chksum) Then
    43.   cmdencrypt.Enabled = True
    44.   cmddecrypt.Enabled = True
    45.   cmdexit.Enabled = True
    46.   Exit Sub
    47. End If
    48. StatusBar1.SimpleText = " Status: Encryption in progress...."
    49. Open full2 For Output As #3
    50. Print #3, chksum
    51. Close #3
    52. Open full For Input As #1
    53. While Not EOF(1)
    54.   Line Input #1, lin
    55.   Open full2 For Append As #3
    56.   rev = reverse(lin)
    57.   For I = 1 To Len(lin)
    58.     encryptfactor = Len(lin) Mod 10
    59.     If encryptfactor = 0 Then
    60.       encryptfactor = Int(Len(lin) / 10)
    61.     End If
    62.     A = Mid(rev, I, 1)
    63.     B = Asc(A) + encryptfactor
    64.     If B > 255 Then
    65.       B = 255
    66.     End If
    67.     temp = temp & Chr(B)
    68.   Next
    69.   Print #3, temp
    70.   temp = ""
    71.   Close #3
    72. Wend
    73. Close #1
    74.  
    75. Kill (full)
    76. FileCopy full2, full
    77. Kill (full2)
    78. StatusBar1.SimpleText = " Status: Encryption completed !"
    79. cmdencrypt.Enabled = True
    80. cmddecrypt.Enabled = True
    81. cmdexit.Enabled = True
    82. StatusBar1.SimpleText = " Status: Ready"
    83. Exit Sub
    84.  
    85. handler2:
    86.   s = MsgBox(Err.Description, vbExclamation, "Error !")
    87.   g = Dir(full2)
    88.   If g <> "" Then
    89.     Kill (full2)
    90.   End If
    91.   cmdencrypt.Enabled = True
    92.   cmddecrypt.Enabled = True
    93.   cmdexit.Enabled = True
    94.  
    95. End Sub

    And Here is the decrypt code:
    VB Code:
    1. Private Sub cmddecrypt_Click()
    2. On Error GoTo handler
    3. cmdencrypt.Enabled = False
    4. cmddecrypt.Enabled = False
    5. cmdexit.Enabled = False
    6. If txtname.Text = "" Then
    7.   cmdencrypt.Enabled = True
    8.   cmddecrypt.Enabled = True
    9.   cmdexit.Enabled = True
    10.   Exit Sub
    11. End If
    12.  
    13. If (UCase(Right(txtname.Text, 3)) <> "TXT") And (UCase(Right(txtname.Text, 3)) <> "INI") And (UCase(Right(txtname.Text, 3)) <> "VBS") And (UCase(Right(txtname.Text, 3)) <> "INF") And (UCase(Right(txtname.Text, 3)) <> "BAT") Then
    14.   cmdencrypt.Enabled = True
    15.   cmddecrypt.Enabled = True
    16.   cmdexit.Enabled = True
    17.   Exit Sub
    18. End If
    19. If Right(Dir1.Path, 1) = "\" Then
    20.    full = txtname.Text
    21. full2 = App.Path & "\temp.tmp"
    22. Else
    23. full = txtname.Text
    24. full2 = App.Path & "\temp.tmp"
    25. End If
    26. Open full For Input As #4
    27. Line Input #4, chk
    28. Close #4
    29.  
    30. If (chk <> "[§Encrypted§]") Then
    31.   cmdencrypt.Enabled = True
    32.   cmddecrypt.Enabled = True
    33.   cmdexit.Enabled = True
    34.   Exit Sub
    35. End If
    36. StatusBar1.SimpleText = " Status: Decryption in progress...."
    37. Open full For Input As #1
    38. Line Input #1, k
    39. While Not EOF(1)
    40.   Line Input #1, lin
    41.   Open full2 For Append As #3
    42.   rev = reverse(lin)
    43.   For I = 1 To Len(lin)
    44.     decryptfactor = Len(lin) Mod 10
    45.     If decryptfactor = 0 Then
    46.       decryptfactor = Int(Len(lin) / 10)
    47.     End If
    48.     A = Mid(rev, I, 1)
    49.     B = Asc(A) - decryptfactor
    50.     temp = temp & Chr(B)
    51.   Next
    52.   Print #3, temp
    53.   temp = ""
    54.   Close #3
    55. Wend
    56. Close #1
    57. Kill (full)
    58. FileCopy full2, full
    59. Kill (full2)
    60. StatusBar1.SimpleText = " Status: Decryption completed !"
    61. cmdencrypt.Enabled = True
    62. cmddecrypt.Enabled = True
    63. cmdexit.Enabled = True
    64. StatusBar1.SimpleText = " Status: Ready"
    65. Exit Sub
    66. handler:
    67.   s = MsgBox(Err.Description, vbExclamation, "Error !")
    68.   g = Dir(full2)
    69.   If g <> "" Then
    70.     Kill (full2)
    71.   End If
    72.   cmdencrypt.Enabled = True
    73.   cmddecrypt.Enabled = True
    74.   cmdexit.Enabled = True
    75.  
    76. End Sub

    The part of this code that bothers me is:
    VB Code:
    1. full = app.path & "\temp.tmp"

    www.google.com - Pay Tribute.

    Always Listening To: Thrice

  2. #2
    Frenzied Member
    Join Date
    Jan 2001
    Location
    Newbury, UK
    Posts
    1,878
    When you say 100's do you mean 100's every time that code runs?
    Or do you mean it creates one file, but the code is actually run 100's of times over a week / month / year??

    And is it the decrypt that creates the files? Or the encrypt?

  3. #3

    Thread Starter
    Fanatic Member cid's Avatar
    Join Date
    Nov 2002
    Location
    Fort Worth, Texas
    Posts
    854
    I mean over a period of time. Like about 100 will be created over a week. And I dont know if the encrypt or decrypt creates the temp files. But I noticed it creates temp files in the app.path. Can I get rid off Full2? And if so how...because when I tried to I got errors.

    www.google.com - Pay Tribute.

    Always Listening To: Thrice

  4. #4

    Thread Starter
    Fanatic Member cid's Avatar
    Join Date
    Nov 2002
    Location
    Fort Worth, Texas
    Posts
    854
    just sending my post to the top of the forum...

    www.google.com - Pay Tribute.

    Always Listening To: Thrice

  5. #5
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385
    cid


    What are the file names of the temp files?

  6. #6

    Thread Starter
    Fanatic Member cid's Avatar
    Join Date
    Nov 2002
    Location
    Fort Worth, Texas
    Posts
    854
    Like...
    2C.tmp
    18.tmp
    10.tmp
    Just junk like that.

    www.google.com - Pay Tribute.

    Always Listening To: Thrice

  7. #7
    Addicted Member
    Join Date
    Jul 2003
    Location
    Lewiston, Maine
    Posts
    128
    I have the same problem with one of my apps. I just put this code in to clean up the .tmp files when my app starts each time. You don't do this during program operation as the .tmp file may be in use. The extension .tmp means temporary so it is not needed after the program has ended.

    VB Code:
    1. Kill App.Path & "\*.tmp"

  8. #8

    Thread Starter
    Fanatic Member cid's Avatar
    Join Date
    Nov 2002
    Location
    Fort Worth, Texas
    Posts
    854
    Sweet...Thanks purdybirds. Ill try what you said and get back to you in about a week...Cause the project is at school and school is closed due to holidays.

    www.google.com - Pay Tribute.

    Always Listening To: Thrice

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width