Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8064351

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T11:20:25+00:00 2026-06-05T11:20:25+00:00

I wrote a simple console tool that reads a file and then writes something

  • 0

I wrote a simple console tool that reads a file and then writes something out. I intend to just drag and drop files and then out pops the output in the same directory as the input file.

All of the testing works, and when I call it from command-line, everything comes out as expected. However, when I tried dragging and dropping it in explorer, no files were created.

I did a search through the system and found that they were all dumped at Documents and Settings under my user folder, and when I printed out the full path that’s what it said.

Which is weird. Wouldn’t Path.GetFullPath return the absolute path of the input file? Instead it looks like it just combined that user directory path to the input’s filename.

EDIT: here’s the code. I feel like I’ve made a logic error somewhere but can’t seem to see it.

filename = System.IO.Path.GetFileName(args[i]);
abspath = Path.GetFullPath(filename);
dirpath = Path.GetDirectoryName(abspath);
....
Console.WriteLine(dirpath);
  • 0 0 Answers
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T11:20:27+00:00Added an answer on June 5, 2026 at 11:20 am

    Path.GetFullPath should return the absolute path of the path string you pass in.

    Path.GetFileName(string path) only returns the filename and extension of the file you pass in. For example, System.IO.Path.GetFileName("C:\SomeDirectory\Test.txt"); would just return “Test.txt”. You’ll want to use the Path.GetDirectoryName to get the path of your input file, like so:

    string inputDirectory = System.IO.Path.GetDirectoryName(args[i]);
    

    Alternately, you can use the FileInfo class to retrieve a bunch more information about your input file. For example:

    // Assuming args[i] = "C:\SomeDirectory\Test.txt"
    FileInfo inputFile = new FileInfo(args[i]);
    string inputDirectory = inputFile.DirectoryName; // "C:\SomeDirectory"
    string inputFileName = inputFile.Name; // "Test.txt"
    string fullInputFile = inputFile.FullName; // "C:\SomeDirectory\Test.txt"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wrote simple class that on the start it just increase the value of
I'm exploring MSMQ services, and I wrote a simple console client-server application that sends
So I wrote this simple console app to aid in my question asking. What
I wrote some sort of console client for a simple application. To be more
I wrote simple load testing tool for testing performance of Java modules. One problem
I wrote a simple XML file and a DTD file including an entity, but
I wrote a simple function, that makes emacs add matching quotes (so when I
I'm very new to lucene.net. I wrote this simple console app in C# which
I wanted to test Mono AOT, so I wrote a simple console application with
I wrote the following simple function that takes two parameters mostly coming from another

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.