nerdexam
Microsoft

98-372 · Question #29

You are creating an application using .NET Framework 4.0. You need to create a name for a new temp file? What is the most efficient way to create the name for a new temp file?

The correct answer is D. Using the GetTempFileName method of the Path class. Using the GetTempFileName method of the Path class is the most efficient way to identify a name for a new temp file. The GetTempFileName method of the Path class is used to create a uniquely named, zero- byte temporary file on disk and returns the full path of the file. It create

Understanding Namespaces and Classes

Question

You are creating an application using .NET Framework 4.0. You need to create a name for a new temp file? What is the most efficient way to create the name for a new temp file?

Options

  • AUsing the GetRandomFileName method of the Path class
  • BUsing the GetFullPath method of the Path class
  • CUsing the GetTempPath method of the Path class
  • DUsing the GetTempFileName method of the Path class

How the community answered

(24 responses)
  • A
    17% (4)
  • B
    4% (1)
  • C
    8% (2)
  • D
    71% (17)

Explanation

Using the GetTempFileName method of the Path class is the most efficient way to identify a name for a new temp file. The GetTempFileName method of the Path class is used to create a uniquely named, zero- byte temporary file on disk and returns the full path of the file. It creates a temporary file with a .TMP file extension. The GetTempFileName method will raise an IOException if it needs to create more than 65,535 files without deleting earlier temporary files. The GetTempFileName method will also raise an IOException if no unique temporary file name is available. To resolve this error, all unnecessary temporary files should be deleted. Answer: C is incorrect. The GetTempPath method of the Path class is used to return the path of the current user's temporary folder. Answer: A is incorrect. The GetRandomFileName method of the Path class is used to return a random folder name or file name. Answer: B is incorrect. The GetFullPath method of the Path class is used to return the absolute path for the specified path string.

Topics

#Path class#GetTempFileName#temp files#file system API

Community Discussion

No community discussion yet for this question.

Full 98-372 Practice