???? ID: 318425 - ????? ???????: 04 ?????? 2010 - ??????: 2.0
TO HOW: ????? ?? ??????? ????????? asp.NET ??? ???? ?? ????? C# .NET ?? ????? ???? ??????? ????
?????? ?????? This article applies to a different operating system than the one you are using. Article content that may not be relevant to you is disabled.
?? ??? ?? ??? ???? ???? ???? ??? ???? ?? ????? ?? Microsoft asp.NET ?? Microsoft Visual C# .NET ?? ????? ???? ??????? ?????????? ?? ??????? ???? ?? ??? ??? ???? ??????? ????? ?? ??? ???? ?????? ??? ??? ???? ?? ?? ??? ????? ?? ???? ??????? ?? ??? ?????? ????????? ?? ?????? ?? ?? ????? ??????? ???????? ?? ???? ??? ????? ?? ???? ?????? ?? retrieves ????? ?? ??? ?? asp.NET ?? ????? C# .NET ?? ????? ?? ???? ???? ??? ?? ??? ?????? ???????? ??????? ??????? ?? ??? ??? ?? ?? ???? ?? ????? ?? ???? ????
??? ???? ?????????? ???????? Microsoft Visual Studio .NET, ??? ???? ????? ??????? ?? ????-????? ????, ?? ???? ???????????? . ???????? C# ????????? ????????ASP.NET ??? ???? . ?????? ?? ???????HTTP://localhost/DocumentManagementService ?? ???????? ?? ????-????? ????, ?? ???? ???OK . ???????? ??? ??, Service1.asmx ????? ?? ?? ??????? ????? ??? ????????? ???? ???? ??? ????? ????????? ???? ??,???: ??? ????? Service1.asmx ?? ??? ????????? ????? ???? ?? ??? ????? WebMethods ??? ??????Service1 ???? :
[WebMethod]
public bool SaveDocument( Byte[] docbinaryarray, string docname)
{
string strdocPath;
strdocPath = "C:\\DocumentDirectory\\" + docname;
FileStream objfilestream =new FileStream(strdocPath,FileMode.Create,FileAccess.ReadWrite);
objfilestream.Write(docbinaryarray,0,docbinaryarray.Length);
objfilestream.Close();
return true;
}
[WebMethod]
public int GetDocumentLen(string DocumentName)
{
string strdocPath;
strdocPath = "C:\\DocumentDirectory\\" + DocumentName;
FileStream objfilestream = new FileStream(strdocPath,FileMode.Open,FileAccess.Read);
int len = (int)objfilestream.Length;
objfilestream.Close();
return len;
}
[WebMethod]
public Byte[] GetDocument(string DocumentName)
{
string strdocPath;
strdocPath = "C:\\DocumentDirectory\\" + DocumentName;
FileStream objfilestream = new FileStream(strdocPath,FileMode.Open,FileAccess.Read);
int len = (int)objfilestream.Length;
Byte[] documentcontents = new Byte[len];
objfilestream.Read(documentcontents,0,len);
objfilestream.Close();
return documentcontents;
}
???:: ??? <root>???? ?? ??? ???????? ?????? ??: ????? ?? \\DocumentDirectory\\ ?????????? ??? ?? ???? ??? ????? ?? ??????? ???? ?? ????????. ?? ?????? ????? ??? ?? ??? ?????????</root> ????? ??? ????? Service1.asmx ?? ???? ??? ??????: ??? ???? ?? ??????? ????:????? ???????? ???? ???? ??,??????? ??? ???? ??????? ????? ?? ??? ??????? ??????? ???? ??, ?? ???? ?? ????? ?? ?????? ????? ?? ????? ???? ??? ????????? ???? ?? ??SaveDocument ,GetDocument , ??GetDocumentLen ??????? ??? ????? ???? ???? ??????? ?? ????? ?? ??? ??? ??????? ????? ?? ??? ????? ??? ???? ?? ??? ??? ??????? ?? ?????????? ???????? Visual Studio .NET, ??? ???? ????? ????????????? ?? ????? ?? ????-????? ????, ?? ???? ?????? ????????? . ?????????? C# ????????? ???? ???, ?? ??? ????Windows ????????? ?? ????-????? ????, ?? ???? ???OK . ???????? ??? ??, Form1 ??? ???? ???? ??.. ??? ???? ?? ??? ???? ??? ?????? ?? ??? ??? ??????:?????? Explorer ???, ??????? ????????? ???? ?? ????-????? ?? ?? ??? ??????? ?????? ?????? ????? ?????????? ???? ??.. ???????? ?????? ?????? ????? ????? ???, ??? ???? ?? ??? ??? ?????? ????? ???? (WSDL) ????? ?? URL ???? ????, ?? ???? ??? ENTER ?????????:: WSDL ????? ?? ??? ??????? ????? ?? http://localhost/DocumentManagementService/Service1.asmx?WSDL ??? ???????? ?????? ?????? ????? ????? ???, ????? ?????????? ?????? . Form1 ?? ??? ?? ??? ??????? ??? ??????? ???? ?? ??? button1 ?? ???????? ?? ?????? ???????? . ??? ??????? ???? ?? ??? button2 ?? ??????????? ????? ?? ??????? ???? . ???-????? ????Button1 , ??button2 to create default Click event handlers for the buttons. Replace the handlers with the following code:
string sFile = "<file path>";
private void button1_Click(object sender, System.EventArgs e)
{
FileStream objfilestream = new FileStream(sFile,FileMode.Open,FileAccess.Read);
int len = (int)objfilestream.Length;
Byte[] mybytearray = new Byte[len];
objfilestream.Read(mybytearray,0,len);
localhost.Service1 myservice = new localhost.Service1();
myservice.SaveDocument(mybytearray,sFile.Remove(0,sFile.LastIndexOf("\\")+1));
objfilestream.Close();
}
private void button2_Click(object sender, System.EventArgs e)
{
MemoryStream objstreaminput = new MemoryStream();
FileStream objfilestream = new FileStream(sFile.Insert(sFile.LastIndexOf("."),"2"), FileMode.Create,FileAccess.ReadWrite);
localhost.Service1 myservice = new localhost.Service1();
int len = (int)myservice.GetDocumentLen(sFile.Remove(0,sFile.LastIndexOf("\\")+1));
Byte[] mybytearray = new Byte[len];
mybytearray = myservice.GetDocument(sFile.Remove(0,sFile.LastIndexOf("\\")+1));
objfilestream.Write(mybytearray,0,len);
objfilestream.Close();
}
???:: ThesFile variable must contain the local file path to a document that will be uploaded to the server. When the document is downloaded, it is placed in the same folder, and a value of2 is appended to the file name. Add the following namespace at the beginning of the file: In Solution Explorer, right-click the client project item. Then selectSet as Startup Project ????? ?????????? ???? ??.. Try It Out????? ???????? ???? ???? ??,??????? . Form1 appears. Click the button labeled????? ?? ?????? ???????? . ?? ??? ????SaveDocument ??? ????? ?? ??? ???? <root>??? ??????? ???????? ?????? ??: ????? ?? \DocumentDirectory\ ???????? ?? ???????? ?? ??????????? ??, ?? ??? ?????? ?? ???? ????? ?? ?????? ???????.</root> ??? ?? ???? ???? ??? ????? ???????????? ????? ?? ??????? ???? . ?? ??? ????GetDocument ??? ????? ?? ??? ???? ?? <root>???????? retrieves: ????? ?? \DocumentDirectory\ ???????? ???????? ??? ???. ????????? ??????? ?????? ?? ????? ??</root> ???? ??????? ?? ??? Microsoft Visual Studio .NET ????????? ??????
???? ???? ???? ??: Microsoft ASP.NET 1.0 Microsoft Visual C# .NET 2002 Standard Edition kbhowtomaster kbmt KB318425 KbMthi
???? ?????? ???????? ??????????: ?? ???? ?? ???? ??????? ?? ????? ?? Microsoft ????-?????? ?????????? ?????? ?????? ???? ??? ??. Microsoft ???? ??? ????-???????? ?? ????-???????? ????? ?????? ?? ???? ???????? ???? ?? ???? ????? ????? ??? ?? ??? ?????? ?? ???? ???? ???? ??? ????? ??. ???????, ????-???????? ???? ????? ???? ???? ???? ???. ?????, ????????, ?????-???? ?? ??????? ?? ???????? ?? ???? ???, ???? ?? ??? ?????? ???? ???? ??? ????? ??? ?? ???? ??. Microsoft ??????? ??? ???? ?? ?????? ?? ??????????, ????????? ?? ??? ?????? ?? ???? ????? ?? ???? ???????? ?? ??? ???? ????? ?? ??? ????????? ???? ??. Microsoft ????-?????? ?????????? ?? ????? ?????? ?? ?? ??? ??.
?????????? ?? ??????? ????????? ??????? ??:
318425
(http://support.microsoft.com/kb/318425/en-us/
)
Was this information helpful?
How much effort did you personally put forth to use this article?
Tell us why and what can we do to improve this information
Thank you! Your feedback is used to help us improve our support content. For more assistance options, please visit the
Help and Support Home Page .
???? ?????? ???? ?????? ??????
??????
??? ?????? ??????? ????
???? ??????