1

I have a C# Windows Service that needs to access to a Linux computer to get a list of files in a particular directory. What .NET 3.5SP1 method would one use that allows me to do this?

Thanks.

Lenard
  • 11
  • 1
  • 2
  • samba fileshares or nfs? –  Mar 31 '10 at 17:24
  • My customer already has a drive letter mapped to the Linux box (via "net use"). There is no problems accessing the folder via Windows Explorer actually. However, as you know, Window services don't have access to drive mappings. I thought there was a Windows network API one could use to pass the log-in credentials to read the Linux file system. – Lenard Apr 01 '10 at 04:34

2 Answers2

4

You'll have to create a Samba (SMB) or NFS share on the Linux box that is accessible from the Windows machine that is running your application.

You can then use the standard tools for working with files/directories in .NET to work with the files.

As mentioned in comments, you could also use the standard FTP libraries which would require configuring an FTP server on your Linux machine. SFTP is also an option...but would require a third party library on the .NET side.

Justin Niessner
  • 242,243
  • 40
  • 408
  • 536
  • S/FTP could also do this (assuming said linux machine is running one of these servers). FTP is built-in, SFTP would need a 3rd party library. – tscho Mar 31 '10 at 17:29
  • S/FTP is not an option with the client. – Lenard Apr 01 '10 at 04:37
  • 1
    I just found this link: http://stackoverflow.com/questions/295538/how-to-provide-user-name-and-password-when-connecting-to-a-network-share. (Don't know why my earlier searches didn't bring it up before.) – Lenard Apr 01 '10 at 04:46
1

Hi you can check at my open source project http://code.google.com/p/nekodrive You can use directly NekoDrive.NFS c# library that wraps my implementation of V2 e V3 NFS Protocol (V4.1 is coming).. It doesn't support the full protocol yet but It works for basic browsing/download/upload functions..

hope this helps