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

  • SEARCH
  • Home
  • 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 3980480
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T05:17:45+00:00 2026-05-20T05:17:45+00:00

HI guys, I only started c# recently so I’m not 100% familiar with it’s

  • 0

HI guys,
I only started c# recently so I’m not 100% familiar with it’s syntax yet and I got into a problem. I’d like to write the current time into a filename. I’m using the following code:

DateTime now = DateTime.now;
string dateString = string.Format(@"Z:\test\{0}.bmp",now.ToString("s"));
bitmap.Save(dateString);

Now this gives me a can’t access filepath error. Apparently it has something to do with the “:” characters at the time part (at least when I give a now.ToString(“d”) ) it saves fine.
Any idea whats causing this? Thanks.

  • 1 1 Answer
  • 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-05-20T05:17:45+00:00Added an answer on May 20, 2026 at 5:17 am

    The “s” format will create a filename of something like:

    2009-06-15T13:45:30.bmp
    

    That’s just not a valid filename, due to the colon. Either replace the colon with another character after calling ToString, or use a different format.

    Note that “d” won’t always work either, as it can include “/” in the name, depending on the culture.

    Personally I’d suggest something like “yyyyMMdd-HHmmss” which will give you something like

    20090615-134530.bmp
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm hoping you guys can answer me a question? I've only just started out
guys. I have a strange problem. I try to write unit-tests to web-app. I
Hey guys, I have an issue whereby only my parent is being inserted into
Hi guys how do i make it display date only. temp.StartDate.Date doesnt work, it
Hi guys first of all I have no expirience with DB programing only basic
Hey Guys, here is my code for this, the only help i get from
Right guys, all autocomplete plugins and functions that I've found, they only update upon
guys, I would like to you evaluate next code below. As you see, I
I know it's not a programming question per-se, but come on guys - give
Problem solved: Thanks guys, see my answer below. I have a website running in

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.