C# Ftp client

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Boris

    C# Ftp client

    I am trying to develop C# ftp client to upload files to remote host.
    Whenever, I execute System.Net.Sock ets.Socket.Conn ect method, .Net Framework
    raises the following exception

    Request for the permission of type System.Net.Sock etPermission, System,
    Version=1.0.500 0.0, Culture=neutral , PublicKeyToken= b77a5c561934e08 9 failed.

    Why does this happen?

    Thanks,
    -Boris



  • Ignacio Machin \( .NET/ C#  MVP \)

    #2
    Re: C# Ftp client

    Hi,

    This may seems like a silly question, but are you running it from a network
    share?

    It seems like a permission issue, maybe the user you are running under does
    not have enough privilegies

    btw, you should use TcpClient instead of Socket, unless you are planning to
    use some low level functions.

    Cheers,

    --
    Ignacio Machin,
    ignacio.machin AT dot.state.fl.us
    Florida Department Of Transportation


    "Boris" <boris@crabel.c om> wrote in message
    news:eIBo$qXoEH A.1176@TK2MSFTN GP12.phx.gbl...[color=blue]
    > I am trying to develop C# ftp client to upload files to remote host.
    > Whenever, I execute System.Net.Sock ets.Socket.Conn ect method, .Net[/color]
    Framework[color=blue]
    > raises the following exception
    >
    > Request for the permission of type System.Net.Sock etPermission, System,
    > Version=1.0.500 0.0, Culture=neutral , PublicKeyToken= b77a5c561934e08 9[/color]
    failed.[color=blue]
    >
    > Why does this happen?
    >
    > Thanks,
    > -Boris
    >
    >
    >[/color]


    Comment

    • Jon Skeet [C# MVP]

      #3
      Re: C# Ftp client

      Boris <boris@crabel.c om> wrote:[color=blue]
      > I am trying to develop C# ftp client to upload files to remote host.
      > Whenever, I execute System.Net.Sock ets.Socket.Conn ect method, .Net Framework
      > raises the following exception
      >
      > Request for the permission of type System.Net.Sock etPermission, System,
      > Version=1.0.500 0.0, Culture=neutral , PublicKeyToken= b77a5c561934e08 9 failed.
      >
      > Why does this happen?[/color]

      Presumably because the machine running the code hasn't given the
      assembly the required level of trust.

      --
      Jon Skeet - <skeet@pobox.co m>
      Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.

      If replying to the group, please do not mail me too

      Comment

      • Nicholas Paldino [.NET/C# MVP]

        #4
        Re: C# Ftp client

        Boris,

        Quite simply, you don't have permission for it to run. Is the code that
        this is running from being downloaded from the web, or from a shared drive?
        If that is the case, then the default settings would prevent you from
        accessing the Socket class.

        Hope this helps.

        --
        - Nicholas Paldino [.NET/C# MVP]
        - mvp@spam.guard. caspershouse.co m

        "Boris" <boris@crabel.c om> wrote in message
        news:eIBo$qXoEH A.1176@TK2MSFTN GP12.phx.gbl...[color=blue]
        >I am trying to develop C# ftp client to upload files to remote host.
        >Whenever, I execute System.Net.Sock ets.Socket.Conn ect method, .Net
        >Framework raises the following exception
        >
        > Request for the permission of type System.Net.Sock etPermission, System,
        > Version=1.0.500 0.0, Culture=neutral , PublicKeyToken= b77a5c561934e08 9
        > failed.
        >
        > Why does this happen?
        >
        > Thanks,
        > -Boris
        >
        >
        >[/color]


        Comment

        • Boris

          #5
          Re: C# Ftp client

          Hi Ignacio,

          Thanks for the response. You are right. I was running it from the network
          share, and as soon as I ran it on local machine, it started working.

          I am trying to implement FTP client to perform the following tasks

          1) Login to remote UNIX server
          2) Create appropriate directory, if not already exists
          3) Upload the file into the directory
          4) Delete file from the directory

          Would TcpClient provide me with this functionality? Do you have any code
          examples?

          Thanks,
          -Boris

          "Ignacio Machin ( .NET/ C# MVP )" <ignacio.mach in AT dot.state.fl.us > wrote
          in message news:%23kBPgtXo EHA.692@TK2MSFT NGP12.phx.gbl.. .[color=blue]
          > Hi,
          >
          > This may seems like a silly question, but are you running it from a
          > network
          > share?
          >
          > It seems like a permission issue, maybe the user you are running under
          > does
          > not have enough privilegies
          >
          > btw, you should use TcpClient instead of Socket, unless you are planning
          > to
          > use some low level functions.
          >
          > Cheers,
          >
          > --
          > Ignacio Machin,
          > ignacio.machin AT dot.state.fl.us
          > Florida Department Of Transportation
          >
          >
          > "Boris" <boris@crabel.c om> wrote in message
          > news:eIBo$qXoEH A.1176@TK2MSFTN GP12.phx.gbl...[color=green]
          >> I am trying to develop C# ftp client to upload files to remote host.
          >> Whenever, I execute System.Net.Sock ets.Socket.Conn ect method, .Net[/color]
          > Framework[color=green]
          >> raises the following exception
          >>
          >> Request for the permission of type System.Net.Sock etPermission, System,
          >> Version=1.0.500 0.0, Culture=neutral , PublicKeyToken= b77a5c561934e08 9[/color]
          > failed.[color=green]
          >>
          >> Why does this happen?
          >>
          >> Thanks,
          >> -Boris
          >>
          >>
          >>[/color]
          >
          >[/color]


          Comment

          • Nicholas Paldino [.NET/C# MVP]

            #6
            Re: C# Ftp client

            Boris,

            The TcpClient will only help you in connecting to the FTP server, it
            will not help you with issuing the commands for the FTP. You still have to
            do that yourself.

            However, in .NET 2.0, there is an FtpWebRequest class, which could make
            much of it easier (if you can use the beta, and roll out after the release).

            Hope this helps.

            --
            - Nicholas Paldino [.NET/C# MVP]
            - mvp@spam.guard. caspershouse.co m

            "Boris" <boris@crabel.c om> wrote in message
            news:%23V6knEYo EHA.2032@TK2MSF TNGP10.phx.gbl. ..[color=blue]
            > Hi Ignacio,
            >
            > Thanks for the response. You are right. I was running it from the
            > network share, and as soon as I ran it on local machine, it started
            > working.
            >
            > I am trying to implement FTP client to perform the following tasks
            >
            > 1) Login to remote UNIX server
            > 2) Create appropriate directory, if not already exists
            > 3) Upload the file into the directory
            > 4) Delete file from the directory
            >
            > Would TcpClient provide me with this functionality? Do you have any code
            > examples?
            >
            > Thanks,
            > -Boris
            >
            > "Ignacio Machin ( .NET/ C# MVP )" <ignacio.mach in AT dot.state.fl.us >
            > wrote in message news:%23kBPgtXo EHA.692@TK2MSFT NGP12.phx.gbl.. .[color=green]
            >> Hi,
            >>
            >> This may seems like a silly question, but are you running it from a
            >> network
            >> share?
            >>
            >> It seems like a permission issue, maybe the user you are running under
            >> does
            >> not have enough privilegies
            >>
            >> btw, you should use TcpClient instead of Socket, unless you are planning
            >> to
            >> use some low level functions.
            >>
            >> Cheers,
            >>
            >> --
            >> Ignacio Machin,
            >> ignacio.machin AT dot.state.fl.us
            >> Florida Department Of Transportation
            >>
            >>
            >> "Boris" <boris@crabel.c om> wrote in message
            >> news:eIBo$qXoEH A.1176@TK2MSFTN GP12.phx.gbl...[color=darkred]
            >>> I am trying to develop C# ftp client to upload files to remote host.
            >>> Whenever, I execute System.Net.Sock ets.Socket.Conn ect method, .Net[/color]
            >> Framework[color=darkred]
            >>> raises the following exception
            >>>
            >>> Request for the permission of type System.Net.Sock etPermission, System,
            >>> Version=1.0.500 0.0, Culture=neutral , PublicKeyToken= b77a5c561934e08 9[/color]
            >> failed.[color=darkred]
            >>>
            >>> Why does this happen?
            >>>
            >>> Thanks,
            >>> -Boris
            >>>
            >>>
            >>>[/color]
            >>
            >>[/color]
            >
            >[/color]


            Comment

            • Ignacio Machin \( .NET/ C#  MVP \)

              #7
              Re: C# Ftp client

              Hi,

              [color=blue]
              > Thanks for the response. You are right. I was running it from the[/color]
              network[color=blue]
              > share, and as soon as I ran it on local machine, it started working.[/color]

              Good to know !
              [color=blue]
              > Would TcpClient provide me with this functionality? Do you have any code
              > examples?[/color]

              TcpClient is a easier way to handle TCP connection, nothing else, you still
              have to implement the ftp protocol.

              I dont have any code unfortunally, but I'm very sure that if you look into
              the archives or online somewhere you will find either a component ready to
              be used or an example of how to implement it.

              cheers,

              --
              Ignacio Machin,
              ignacio.machin AT dot.state.fl.us
              Florida Department Of Transportation



              Comment

              • Fakher Halim

                #8
                Re: C# Ftp client

                For finer control, you may want to try


                Fakher Halim


                "Ignacio Machin ( .NET/ C# MVP )" <ignacio.mach in AT dot.state.fl.us > wrote
                in message news:uUTm#WZoEH A.3564@tk2msftn gp13.phx.gbl...[color=blue]
                > Hi,
                >
                >[color=green]
                > > Thanks for the response. You are right. I was running it from the[/color]
                > network[color=green]
                > > share, and as soon as I ran it on local machine, it started working.[/color]
                >
                > Good to know !
                >[color=green]
                > > Would TcpClient provide me with this functionality? Do you have any[/color][/color]
                code[color=blue][color=green]
                > > examples?[/color]
                >
                > TcpClient is a easier way to handle TCP connection, nothing else, you[/color]
                still[color=blue]
                > have to implement the ftp protocol.
                >
                > I dont have any code unfortunally, but I'm very sure that if you look into
                > the archives or online somewhere you will find either a component ready to
                > be used or an example of how to implement it.
                >
                > cheers,
                >
                > --
                > Ignacio Machin,
                > ignacio.machin AT dot.state.fl.us
                > Florida Department Of Transportation
                >
                >
                >[/color]


                Comment

                • Jeff Clausius

                  #9
                  Re: C# Ftp client

                  Boris:

                  Unless writing your own FTP client is a learning excersize, I'd recommend
                  against re-inventing the wheel, so to speak.

                  Check out http://www.indyproject.org/indy.html for more information.

                  Jeff


                  "Boris" <boris@crabel.c om> wrote in
                  news:#V6knEYoEH A.2032@TK2MSFTN GP10.phx.gbl:
                  [color=blue]
                  > Hi Ignacio,
                  >
                  > Thanks for the response. You are right. I was running it from the
                  > network share, and as soon as I ran it on local machine, it started
                  > working.
                  >
                  > I am trying to implement FTP client to perform the following tasks
                  >
                  > 1) Login to remote UNIX server
                  > 2) Create appropriate directory, if not already exists
                  > 3) Upload the file into the directory
                  > 4) Delete file from the directory
                  >
                  > Would TcpClient provide me with this functionality? Do you have any
                  > code examples?
                  >
                  > Thanks,
                  > -Boris
                  >
                  > "Ignacio Machin ( .NET/ C# MVP )" <ignacio.mach in AT dot.state.fl.us >
                  > wrote in message news:%23kBPgtXo EHA.692@TK2MSFT NGP12.phx.gbl.. .[color=green]
                  >> Hi,
                  >>
                  >> This may seems like a silly question, but are you running it from a
                  >> network
                  >> share?
                  >>
                  >> It seems like a permission issue, maybe the user you are running
                  >> under does
                  >> not have enough privilegies
                  >>
                  >> btw, you should use TcpClient instead of Socket, unless you are
                  >> planning to
                  >> use some low level functions.
                  >>
                  >> Cheers,
                  >>
                  >> --
                  >> Ignacio Machin,
                  >> ignacio.machin AT dot.state.fl.us
                  >> Florida Department Of Transportation
                  >>
                  >>
                  >> "Boris" <boris@crabel.c om> wrote in message
                  >> news:eIBo$qXoEH A.1176@TK2MSFTN GP12.phx.gbl...[color=darkred]
                  >>> I am trying to develop C# ftp client to upload files to remote host.
                  >>> Whenever, I execute System.Net.Sock ets.Socket.Conn ect method, .Net[/color]
                  >> Framework[color=darkred]
                  >>> raises the following exception
                  >>>
                  >>> Request for the permission of type System.Net.Sock etPermission,
                  >>> System, Version=1.0.500 0.0, Culture=neutral ,
                  >>> PublicKeyToken= b77a5c561934e08 9[/color]
                  >> failed.[color=darkred]
                  >>>
                  >>> Why does this happen?
                  >>>
                  >>> Thanks,
                  >>> -Boris
                  >>>
                  >>>
                  >>>[/color]
                  >>
                  >>[/color]
                  >
                  >[/color]

                  Comment

                  Working...