Autor Beitrag
gordon65 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 27



BeitragVerfasst: Di 19.01.10 16:47 
ja, die datei was ich uploaden will hat auch einen Inhalt
Kha
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3803
Erhaltene Danke: 176

Arch Linux
Python, C, C++ (vim)
BeitragVerfasst: Di 19.01.10 18:37 
Schau dir user profile iconDareDevils Code noch einmal an, besonders das File.Create solltest du überdenken.

user profile icondanielf hat folgendes geschrieben Zum zitierten Posting springen:
wieso verwendest du nicht die Methode UploadFile?
Ich hab's schon aufgegeben :P .

_________________
>λ=


Zuletzt bearbeitet von Kha am Di 19.01.10 18:45, insgesamt 1-mal bearbeitet
danielf
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1012
Erhaltene Danke: 24

Windows XP
C#, Visual Studio
BeitragVerfasst: Di 19.01.10 18:43 
:rofl:

Das Hilft ihm bestimmt ;)
gordon65 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 27



BeitragVerfasst: Di 19.01.10 19:42 
hääää,

irgendwie blick ich gar nicht mehr durch...

was passt jetzt nicht an file.Create

mmh. was ist mit

FileStream fs = File.OpenRead(inputfilepath);
byte[] buffer = new byte[fs.Length];

oder so ... ????
Kha
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3803
Erhaltene Danke: 176

Arch Linux
Python, C, C++ (vim)
BeitragVerfasst: Di 19.01.10 20:18 
Ja, darauf wollte ich hinaus :D .
Aber ich sehe gerade, dass user profile iconDareDevils Code viiel zu komplex ist, nimm einfach File.ReadAllBytes.

(oder UploadFile...)

_________________
>λ=
gordon65 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 27



BeitragVerfasst: Do 21.01.10 18:00 
na also mit File.ReadAllBytes funktioniert es ohne probleme ....

Hier nochmal der funktionierende upload und download

Upload:
ausblenden C#-Quelltext
1:
2:
3:
4:
WebClient request = new WebClient();
request.Credentials = new NetworkCredential("*Benutzername*""*Passwort*");
byte[] fileData = File.ReadAllBytes("hallo.txt");
request.UploadData("ftp://*Server*/files" + "/" + "MyFile.txt", fileData);


warum so kompliziert?? funktioniert doch mit 4 zeilen :)

Download

ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
WebClient request = new WebClient();
request.Credentials = new NetworkCredential("*Benutzername*""*Passwort*");

byte[] fileData = request.DownloadData(@"ftp://*Server*/files" + "/" +     "MyFile.txt");

FileStream file = File.Create(@"C:\test2" + "\\" + "MyFile.txt");

file.Write(fileData, 0, fileData.Length);
file.Close();



im internet waren immer so komplizierte beispiele .... kein wunder warum ich da nicht mehr durchgestiegen bin.


ich bedankt mich erst mal (ganz besonders bei Kha):

Danke für alles ...
danielf
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1012
Erhaltene Danke: 24

Windows XP
C#, Visual Studio
BeitragVerfasst: Do 21.01.10 18:18 
Geht auch mit einer Zeile... und viel lesbarer...