Skip to main content

System.IO.File-like in Python.

Project description

csharp-like-file

If you've ever used C# and found yourself missing the sheer convenience of System.IO.File and System.IO.Directory, you're not alone. I've always loved how those static methods make file operations feel so effortless, so I decided to bring that same "vibe" to Python.

I originally built this just to scratch my own itch, so it's not meant to be some over-engineered masterpiece. It's just a straightforward tool to help you get things done. If you run into a bug or realize I missed a standard C# method you can't live without, just give me a shout in the issues!

Quick Example

import csdir
import csfile

directory = csdir.create_directory("test_folder")  # This returns a pathlib.Path object
csfile.write_all_text(directory / "hello.txt", "Hello World")

Differences from the C# Version

There are a couple of small "cultural" differences between Python and C# that you should know about.

Encoding (encoding)

I've set the default text encoding to UTF-8. I'm not a big fan of C#'s Encoding.Default (which can be a bit unpredictable depending on your OS). You can always pass your own encoding parameter if you need something specific.

Path Resolution

In C#, a path like a/b/.. is usually treated as a pure string operation. In that world, it always simplifies to a. But sometimes, if b is actually a symlink pointing somewhere else, you may expect that .. should take you to the real parent of that target.

However, the meaning of delete and exist clear, we kept the C# behavior. Therefore, when you call delete on a symlink file, it will certainly removing the symlink itself, rather than its destination. If you want to resolve the symlinks, call pathlib.Path.resolve or os.path.realpath before passing the paths into this package.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

csharp_like_file-0.0.8.tar.gz (2.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

csharp_like_file-0.0.8-py3-none-any.whl (3.3 kB view details)

Uploaded Python 3

File details

Details for the file csharp_like_file-0.0.8.tar.gz.

File metadata

  • Download URL: csharp_like_file-0.0.8.tar.gz
  • Upload date:
  • Size: 2.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.28 {"installer":{"name":"uv","version":"0.9.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for csharp_like_file-0.0.8.tar.gz
Algorithm Hash digest
SHA256 e936f3cbda6140dd24258ddc851a572a3e21101be8e31a2cf5090ba51977f271
MD5 5c6bcc1e92f98139f9bdb1c27987d33d
BLAKE2b-256 55f7140b7b6dce0b3ce72305ea3bcd3db02902146eeae4a6b928338304d48f0d

See more details on using hashes here.

File details

Details for the file csharp_like_file-0.0.8-py3-none-any.whl.

File metadata

  • Download URL: csharp_like_file-0.0.8-py3-none-any.whl
  • Upload date:
  • Size: 3.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.28 {"installer":{"name":"uv","version":"0.9.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for csharp_like_file-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 270b2ce9ef34151c0f4ebc3966f4e3d902d51d88e0ab17b1f893ff41ac08464f
MD5 48193a27953762d0a36c5e7e6f877b15
BLAKE2b-256 92abd91d94423bc0c80c0a391d9d06472e9b5f1015acaed9c0c838db468a7128

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page