Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. To write file to other system on LAN

To write file to other system on LAN

Scheduled Pinned Locked Moved C#
question
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    RimiAsh
    wrote on last edited by
    #1

    We use File.WriteAllBytes("//full path",byteArray) to write file on the drive of the system we are working. But if we want that instead of writing on the same system, it writes on other system on the LAN while we have the privileges to write it then what should be given as parameters in this method or is their any other class that support this?

    D 1 Reply Last reply
    0
    • R RimiAsh

      We use File.WriteAllBytes("//full path",byteArray) to write file on the drive of the system we are working. But if we want that instead of writing on the same system, it writes on other system on the LAN while we have the privileges to write it then what should be given as parameters in this method or is their any other class that support this?

      D Offline
      D Offline
      Dustin Metzgar
      wrote on last edited by
      #2

      Can you map a network drive to that directory and write it that way?

      R 1 Reply Last reply
      0
      • D Dustin Metzgar

        Can you map a network drive to that directory and write it that way?

        R Offline
        R Offline
        RimiAsh
        wrote on last edited by
        #3

        No .... without maping the network drive ....is it possible? if it is then how??

        D 1 Reply Last reply
        0
        • R RimiAsh

          No .... without maping the network drive ....is it possible? if it is then how??

          D Offline
          D Offline
          Dustin Metzgar
          wrote on last edited by
          #4

          Well, you should be able to write to a UNC path, but it would have a lot to do with permissions. Your application may be running under a different identity or a lower trust level than is required. For instance, I can successfully run this code on my network:

          static void Main(string[] args) {
          FileInfo fi = new FileInfo(@"\\othermachine\C$\IAmATest.txt");
          using (StreamWriter sw = new StreamWriter(fi.OpenWrite())) {
          sw.WriteLine("Hello World!");
          }
          fi.Delete();
          }

          There's nothing special required to write to this particular path. I have this inside a command line app and I'm running on a domain account, so I know that I have access to write to that path. If you're running under an NT service or IIS, you may want to impersonate a different user account.


          Logifusion[^]

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups