I want to do versioning for text files which are stored in folder.
Each time the user opens the file from the application he edits and saves, this should become new version. later the versions should be displayed near the file name..

Anyone please give me an idea of how to do this????

regards
venkat

Dani AI

Generated

Plain files do not carry history themselves, so store history beside the file rather than inside it. pointed this out and suggested embedding version info in the name — both are useful starting points for a practical design. For , the simplest, robust pattern is: keep the current filename for easy opening, and write each saved snapshot as a separate versioned file plus a small manifest that lists versions (id, timestamp, user, comment, path).

Suggested workflow:

  • On save, generate a version id (either a timestamp or a monotonic counter) and write the snapshot to a versioned filename (choose safe characters; avoid ":" on Windows).
  • Update a manifest (JSON or a tiny SQLite table) with metadata so the UI can quickly show “v3 — 2025-10-25 14:03 — alice” next to the name without scanning the folder.
  • Optionally keep a stable pointer (symlink or copy) named like document.txt.current for programs that expect a fixed path. Compress or store deltas for old versions to save space.

Design notes and cautions:

  • Timestamps avoid locking but don’t give a simple ordinal; counters are human-friendly but require atomic increments (use the manifest DB).
  • Handle concurrent edits with optimistic checks (compare base version) or short locks; offer merge when conflicts occur.
  • Enforce filename safety, permissions, retention/cleanup, and consider using an existing VCS (Git/Mercurial) if you need advanced diffs, branching, or many collaborators.

Recommended Answers

All 5 Replies

Text files cant hold versions directly so theres really only 1 option left.

What do you think that could be

Very great answer Lizr, I like it and in general your way in solving people questions (Y)

each time user uploads a new file with same name can it be possible to make versions

mmmm, can't you extend its name to hold the date?

or an incremental number

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.