Whats wrong here? URI not supported

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine

I made a code. The problem is I get this error:

URI not supported

This code will select image urls, download, then upload using ftp. I guess the problem is at ftp sub
Imports System.Text.RegularExpressions
Imports System.Net
Imports System.IO

Public Class Form3

Private Sub Form3_Load()
Try
Dim mydir As String = Form2.TextBox2.Text
Dim savetxt As New List(Of String)
For Each txtfile As String In System.IO.Directory.GetFiles(mydir, "*.txt") sadece txt dosyalarını alıyor. Hepsi için ayarlanabilir.
For Each line As String In System.IO.File.ReadAllLines(txtfile, System.Text.Encoding.UTF8)
Dim regex As Regex = New Regex( _
"(?<=]).*?(?=[)", _
RegexOptions.Multiline _
Or RegexOptions.CultureInvariant _
Or RegexOptions.IgnorePatternWhitespace _
Or RegexOptions.Compiled _
)
Dim m As Match = regex.Match(line)
If (m.Success) Then
Dim cnttest As String = m.Value
If cnttest.Contains(".png") Then
ListBox1.Items.Add(m.Value) xboost@windowslive.com
Else
If cnttest.Contains(".bmp") Then
ListBox1.Items.Add(m.Value)
Else
If cnttest.Contains(".gif") Then
ListBox1.Items.Add(m.Value)
Else
If cnttest.Contains(".tif") Then
ListBox1.Items.Add(m.Value)
Else
If cnttest.Contains(".jpg") Then
ListBox1.Items.Add(m.Value)
Else
ListBox3.Items.Add(m.Value) xboost@windowslive.com
End If
End If
End If
End If
End If
End If
savetxt.Add(line)
Next
System.IO.File.WriteAllLines(txtfile, savetxt.ToArray)
savetxt.Clear()
Timer2.Start()
ProgressBar1.Style = ProgressBarStyle.Blocks
ProgressBar1.Maximum = ListBox1.Items.Count
Next
Label2.Text = "Aşama 2: FTPye yükleniyor ve txtler düzenleniyor..."
Label3.Text = "Bulunan resimler: " & ListBox1.Items.Count & " Bulunan diğer URLler: " & ListBox3.Items.Count & " yüklenme durumu durum çunuğundadır..."
Catch ex As Exception
MsgBox("Hata!" + vbNewLine + "Olası sebepler:" + vbNewLine + "Klasör seçilmedi" + vbNewLine + "İnternette problem var", MsgBoxStyle.Critical, "Error")
Exit Sub
End Try
End Sub
Private Sub ftp()
Me.Size = New Size(458, 24)
My.Computer.FileSystem.CreateDirectory(Application.StartupPath + "/Sil")
Do Until ListBox1.Items.Count = 0
Try
Dim dosy As String = ListBox1.Items.Item(0)
Dim ext As String
Dim cnttest As String = dosy
If cnttest.Contains(".png") Then
ext = ".png" xboost@windowslive.com
Else
If cnttest.Contains(".bmp") Then
ext = ".bmp"
Else
If cnttest.Contains(".gif") Then
ext = ".gif"
Else
If cnttest.Contains(".tif") Then
ext = ".tif"
Else
If cnttest.Contains(".jpg") Then
ext = ".jpg" xboost@windowslive.com
End If
End If
End If
End If
End If

Dim dosyaa As String = Application.StartupPath + "/temp" + ext
Dim web_client As WebClient = New WebClient
web_client.DownloadFile(dosy, Application.StartupPath + "/temp" + ext)

Dim istek As FtpWebRequest = FtpWebRequest.Create(My.Settings.ftp + "/" + My.Settings.tempname + ext)
With istek
.Credentials = New NetworkCredential(My.Settings.user, My.Settings.pass)
.KeepAlive = False
.Method = WebRequestMethods.Ftp.UploadFile
.ContentLength = (New FileInfo(dosy)).Length
.UsePassive = True
End With
Dim akis As Stream = istek.GetRequestStream
Dim dosya As New FileStream(dosy, FileMode.Open)
Dim okunanAdet As Integer = 0
Dim okunanlar(1024) As Byte
Do
okunanAdet = dosya.Read(okunanlar, 0, 1024)
akis.Write(okunanlar, 0, okunanAdet)
Loop Until okunanAdet = 0
dosya.Close()
akis.Close()
Dim yanit As FtpWebResponse = DirectCast(istek.GetResponse, FtpWebResponse)
ListBox4.Items.Add(yanit.StatusDescription)
Dim mydir As String = Form2.TextBox2.Text
Dim savetxt As New List(Of String)
For Each txtfile As String In System.IO.Directory.GetFiles(mydir, "*.txt") sadece txt dosyalarını alıyor. Hepsi için ayarlanabilir.
For Each line As String In System.IO.File.ReadAllLines(txtfile, System.Text.Encoding.UTF8)
If line.Contains(ListBox1.Items(0)) Then
line = line.Replace(ListBox1.Items(0), My.Settings.url + "/" + My.Settings.tempname + ext)
End If
savetxt.Add(line)
Next
System.IO.File.WriteAllLines(txtfile, savetxt.ToArray)
savetxt.Clear()
Next
My.Settings.tempname = My.Settings.tempname + 1
My.Settings.Save()
ListBox1.Items.Remove(0)
ProgressBar1.Value = ProgressBar1.Value + 1
If ProgressBar1.Value = ProgressBar1.Maximum Then
MsgBox("İşlem tamam!", MsgBoxStyle.Information, "Başarılı")
Me.Close()
End If
Dim valü As String = ListBox1.Items.Count
Button2.Text = "Kalan Resim: " & valü
Catch ex As Exception
MsgBox("Hata!" + vbNewLine + "Olası sebepler:" + vbNewLine + "Klasör seçilmedi" + vbNewLine + "İnternette problem var", MsgBoxStyle.Critical, "Error") xboost@windowslive.com
End Try
Loop
End Sub

Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Timer1.Stop()
Form3_Load()
End Sub

Private Sub Timer2_Tick(sender As Object, e As EventArgs) Handles Timer2.Tick
Timer2.Stop()
ftp()
End Sub
End Class

I get URI not supported error on theese lines:
.ContentLength = (New FileInfo(dosy)).Length
Dim dosya As New FileStream(dosy, FileMode.Open)

View the full article
 

Similar threads

J
Replies
0
Views
140
John2000k
J
E
Replies
0
Views
100
extream87
E
I
Replies
0
Views
156
Innovators World Wide
I
Back
Top