get user directory of file in c#
using (OpenFileDialog openFileDialog = new OpenFileDialog())
{
// TODO: Use LocalUser instead of Hardcode
openFileDialog.InitialDirectory = @"C:\Users\username\Desktop";
openFileDialog.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
openFileDialog.FilterIndex = 2;
openFileDialog.RestoreDirectory = true;
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
//Get the path of specified file
filePath = openFileDialog.FileName;
//Read the contents of the file into a stream
var fileStream = openFileDialog.OpenFile();
using (StreamReader reader = new StreamReader(fileStream))
{
fileContent = reader.ReadToEnd();
}
}
}
Also in C#:
- linq query select top 1 c#
- open udp socket c#
- singleton unity
- .net core executenonqueryasync transaction
- transform.Translate movement
- if else statement
- c# checksum
- c# typeof
- c# how to use inovke
- unity transfoprm position y change
- c# length of array
- get number of sundays in a month c#
- C# webclient immitate browser
- unity c# public all codes
- escape double quotes c#
- how to put double quotes in a string c#
- csharp attributes as generics constraints
- c# multi threading example
- transform.translate unity
- c# string code ascii
- go to next itiration in foreach C#
- isGrounded script for copy
- delay in unity
- dynamic group by expression C#