TO HOW: ????? ?? ??????? ????????? asp.NET ??? ???? ?? ????? C# .NET ?? ????? ???? ??????? ????

???? ?????? ???? ??????
???? ID: 318425 - ?? ???????? ?? ?????? ??? ?? ?? ???? ???? ???? ??.
??? ?? ??????? ???? | ??? ?? ??????? ????

?? ????? ??

??????

?? ??? ?? ??? ???? ???? ???? ??? ???? ?? ????? ?? Microsoft asp.NET ?? Microsoft Visual C# .NET ?? ????? ???? ??????? ?????????? ?? ??????? ???? ?? ??? ??? ???? ??????? ????? ?? ??? ???? ?????? ??? ??? ???? ?? ?? ??? ????? ?? ???? ??????? ?? ??? ?????? ????????? ?? ?????? ?? ?? ????? ??????? ???????? ?? ???? ??? ????? ?? ???? ?????? ?? retrieves ????? ?? ??? ?? asp.NET ?? ????? C# .NET ?? ????? ?? ???? ???? ??? ?? ??? ?????? ???????? ??????? ??????? ?? ??? ??? ?? ?? ???? ?? ????? ?? ???? ????

??? ???? ?????

  1. ????? ????????Microsoft Visual Studio .NET, ??? ???? ????? ????????? ????-????? ????, ?? ???? ????????????.
  2. ???????? C# ?????????????????ASP.NET ??? ????. ?????? ?? ???????HTTP://localhost/DocumentManagementService?? ?????????? ????-????? ????, ?? ???? ???OK. ???????? ??? ??, Service1.asmx ????? ?? ?? ??????? ????? ??? ????????? ???? ???? ???
  3. ????? ????????????? ??,???:??? ????? Service1.asmx ?? ??? ????????? ?????
  4. ???? ?? ??? ????? 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>

  5. ????? ??? ????? Service1.asmx ?? ???? ??? ??????:
    using System.IO;
  6. ??? ???? ?? ??????? ????:
    1. ????? ???????? ???????? ??,?????????? ???? ??????? ????? ?? ??? ??????? ??????? ???? ??, ?? ???? ?? ????? ?? ?????? ????? ?? ????? ???? ???
    2. ????????? ???? ?? ??SaveDocument,GetDocument, ??GetDocumentLen??????? ??? ????? ???? ????
    3. ??????? ?? ????? ?? ??? ??? ??????? ????? ?? ??? ?????

??? ???? ?? ??? ??? ??????? ?? ?????

  1. ????? ????????Visual Studio .NET, ??? ???? ????? ????????????? ?? ??????? ????-????? ????, ?? ???? ?????? ?????????.
  2. ?????????? C# ????????????? ???, ?? ??? ????Windows ??????????? ????-????? ????, ?? ???? ???OK. ???????? ??? ??, Form1 ??? ???? ???? ??..
  3. ??? ???? ?? ??? ???? ??? ?????? ?? ??? ??? ??????:
    1. ?????? Explorer ???, ??????? ????????? ???? ?? ????-????? ?? ?? ??? ??????? ?????? ??????????? ?????????????? ??..
    2. ???????? ?????? ??????????? ????? ???, ??? ???? ?? ??? ??? ?????? ????? ???? (WSDL) ????? ?? URL ???? ????, ?? ???? ??? ENTER ??????

      ???::WSDL ????? ?? ??? ??????? ????? ?? http://localhost/DocumentManagementService/Service1.asmx?WSDL ???
    3. ???????? ?????? ??????????? ????? ???, ????? ?????????? ??????.
  4. Form1 ?? ??? ?? ??? ??????? ??? ??????????? ?? ??? button1 ?? ???????? ?? ?????? ????????. ??? ??????????? ?? ??? button2 ?? ??????????? ????? ?? ??????? ????.
  5. ???-????? ????Button1, ??button2to create default Click event handlers for the buttons.
  6. 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();
    }
    					
    ???::ThesFilevariable 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 of2is appended to the file name.

  7. Add the following namespace at the beginning of the file:
    using System.IO;
  8. In Solution Explorer, right-click the client project item. Then selectSet as Startup Project????? ?????????????? ??..

Try It Out

  1. ????? ???????? ???????? ??,???????. Form1 appears.
  2. Click the button labeled????? ?? ?????? ????????. ?? ??? ????SaveDocument??? ????? ?? ??? ???? <root>??? ??????? ???????? ?????? ??: ????? ?? \DocumentDirectory\ ???????? ?? ???????? ?? ??????????? ??, ?? ??? ?????? ?? ???? ????? ?? ?????? ???????.</root>
  3. ??? ?? ???? ???? ??? ????? ???????????? ????? ?? ??????? ????. ?? ??? ????GetDocument??? ????? ?? ??? ???? ?? <root>???????? retrieves: ????? ?? \DocumentDirectory\ ???????? ???????? ??? ???. ????????? ??????? ?????? ?? ????? ??</root>

??????

???? ??????? ?? ??? Microsoft Visual Studio .NET ????????? ??????

???

???? ID: 318425 - ????? ???????: 04 ?????? 2010 - ??????: 2.0
???? ???? ???? ??:
  • Microsoft ASP.NET 1.0
  • Microsoft Visual C# .NET 2002 Standard Edition
??????: 
kbhowtomaster kbmt KB318425 KbMthi
???? ?????? ????????
??????????: ?? ???? ?? ???? ??????? ?? ????? ?? Microsoft ????-?????? ?????????? ?????? ?????? ???? ??? ??. Microsoft ???? ??? ????-???????? ?? ????-???????? ????? ?????? ?? ???? ???????? ???? ?? ???? ????? ????? ??? ?? ??? ?????? ?? ???? ???? ???? ??? ????? ??. ???????, ????-???????? ???? ????? ???? ???? ???? ???. ?????, ????????, ?????-???? ?? ??????? ?? ???????? ?? ???? ???, ???? ?? ??? ?????? ???? ???? ??? ????? ??? ?? ???? ??. Microsoft ??????? ??? ???? ?? ?????? ?? ??????????, ????????? ?? ??? ?????? ?? ???? ????? ?? ???? ???????? ?? ??? ???? ????? ?? ??? ????????? ???? ??. Microsoft ????-?????? ?????????? ?? ????? ?????? ?? ?? ??? ??.
?????????? ?? ??????? ????????? ??????? ??:318425

??????????? ???

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com