locked
asmx webmethod...code... RRS feed

  • Question

  • User442781244 posted

    Hi

    guys

    i am writing 1 webmethod for receiving PDF file  sent by  other website user....here is the code

    <WebMethod()> _
    Public Sub GetFile(ByVal fileBytes As Byte(), ByVal fileName As String, ByVal USER_ID As Integer)
            System.IO.File.WriteAllBytes(Path.Combine(Server.MapPath("~"), fileName), fileBytes)        
        End Sub
    End Class

    Above code will write file to application root folder with given file name...

    but  in root folder i want to  create the folder  by the name of that userid and store the pdf file in that folder.

    So how to acheive this one??

    Monday, December 2, 2013 12:11 AM

Answers

  • User442781244 posted

    guys i tried this but getting error i.e  Var is not defined

    Dim path As var = String.Format("~/{0}/", USER_ID)
            Dim folder As var = Server.MapPath(path)
            If Not Directory.Exists(folder) Then
                Directory.CreateDirectory(folder)
            End If
            System.IO.File.WriteAllBytes(path.Combine(Server.MapPath(path), fileName), fileByte

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, December 2, 2013 1:02 AM

All replies

  • User442781244 posted

    guys'

    i am thinking this code of lines:

    System.IO.File.WriteAllBytes(Path.Combine(Server.MapPath("~/USER_ID/"), fileName), fileBytes)

    for above requirementt..code is ok or not?? ..suppose  userid i.e 23 has A,pdf,d.pdf  and       24 has e.pdf,r.pdf......this should be stored in two different folder..

    above code is doing that???plz suggest

                               

    Monday, December 2, 2013 12:13 AM
  • User442781244 posted

    guys i tried this but getting error i.e  Var is not defined

    Dim path As var = String.Format("~/{0}/", USER_ID)
            Dim folder As var = Server.MapPath(path)
            If Not Directory.Exists(folder) Then
                Directory.CreateDirectory(folder)
            End If
            System.IO.File.WriteAllBytes(path.Combine(Server.MapPath(path), fileName), fileByte

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, December 2, 2013 1:02 AM