C# Web Service File Transfer
http://articles.techrepublic.com.com/5100-10878_11-5805105.html
using System;
using System.Web.Services;
using System.Xml.Serialization;
using System.IO;
[WebService(Namespace="http://someplace.com/FileIO/")]
public class FileRW : WebService {
[WebMethod]
public byte[] GetFile(string filename) {
BinaryReader binReader = new
BinaryReader(File.Open(Server.MapPath(filename), FileMode.Open,
FileAccess.Read));
binReader.BaseStream.Position = 0;
byte[] binFile =
binReader.ReadBytes(Convert.ToInt32(binReader.BaseStream.Length));
binReader.Close();
return binFile;
}
[WebMethod]
public void PutFile(byte[] buffer, string filename) {
BinaryWriter binWriter = new
BinaryWriter(File.Open(Server.MapPath(filename), FileMode.CreateNew,
FileAccess.ReadWrite));
binWriter.Write(buffer);
binWriter.Close();
}
}
0 Yorum:
Yorum Gönder
Kaydol: Kayıt Yorumları [Atom]
<< Ana Sayfa