Sending a file as an argument to a method?

Is it possible:

public static void DoThis(file aFile){
    //Blah blah blah
}
+3
source share
4 answers

It depends on what you need to do :)

Options include:

  • path (string)
  • contents (string or byte [])
  • some kind of complex object model (of your choice) of content
  • Fileinfo
  • FileStream (or just a stream)
  • some reader / writer; TextReader, XmlWriter, etc.
+5
source

That's right. If you have a link to a file in the calling method, you can do this.

0
source

, . ....

public static void DoThis(file aFile)
{
    if ( aFile == null ) { // report error or whatever }
    //Blah blah blah
}
0

, , - , - . , .

0

Source: https://habr.com/ru/post/1791271/


All Articles