How to combine strings into a path in C#

2 Answers

0 votes
using System;
using System.IO;

public class Program
{
    public static void Main()
    {
        var path = Path.Combine("/home", "dev", "log.txt");
        
        Console.WriteLine(path);
    }
}




/*
run:

/home/dev/log.txt

*/

 



answered Jul 13, 2023 by avibootz
0 votes
using System;
using System.IO;

public class Program
{
    public static void Main()
    {
        var path = Path.Combine("/home/dev/", "/home/dev/log.txt");  
        
        Console.WriteLine(path);
    }
}




/*
run:

/home/dev/log.txt

*/

 



answered Jul 13, 2023 by avibootz

Related questions

2 answers 150 views
1 answer 142 views
3 answers 104 views
1 answer 145 views
1 answer 165 views
1 answer 185 views
...