Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Change file size

Change file size

Scheduled Pinned Locked Moved Visual Basic
tutorial
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    WESHILL
    wrote on last edited by
    #1

    Hi, Does anyone know how I could change the size description of a file without affecting the physical size. For example we could change a file's access date/time with "File.SetLastAccessTime(Path, AccessedDateTime)". I tried the following but it used/reserved the disk space I specified with sizeInBytes. fs = New System.IO.FileStream(Path, IO.FileMode.Open) fs.SetLength(sizeInBytes) Really i would like to make a 0 byte file look like 10mb for example. Thanks Wes...

    D 1 Reply Last reply
    0
    • W WESHILL

      Hi, Does anyone know how I could change the size description of a file without affecting the physical size. For example we could change a file's access date/time with "File.SetLastAccessTime(Path, AccessedDateTime)". I tried the following but it used/reserved the disk space I specified with sizeInBytes. fs = New System.IO.FileStream(Path, IO.FileMode.Open) fs.SetLength(sizeInBytes) Really i would like to make a 0 byte file look like 10mb for example. Thanks Wes...

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      Then your going to have to fill it or reserve the 10MB worth of nothing and yes, it will actually take up the disk space. The size is not a kind of description attribute of the file, but rather the actual size of the file returned by the file system. RageInTheMachine9532

      A 1 Reply Last reply
      0
      • D Dave Kreskowiak

        Then your going to have to fill it or reserve the 10MB worth of nothing and yes, it will actually take up the disk space. The size is not a kind of description attribute of the file, but rather the actual size of the file returned by the file system. RageInTheMachine9532

        A Offline
        A Offline
        Anonymous
        wrote on last edited by
        #3

        That's too bad. However, I have seen this done before. The software that does it is DiskXtender by EMC/Legato. They are able to display a fake value in the size field. DiskXtender is a HSM product that basically migrates the original file's data to tape storage and leaves a stub file behind that looks identical to the original except for the actual size. Thanks, Wes...

        D 1 Reply Last reply
        0
        • A Anonymous

          That's too bad. However, I have seen this done before. The software that does it is DiskXtender by EMC/Legato. They are able to display a fake value in the size field. DiskXtender is a HSM product that basically migrates the original file's data to tape storage and leaves a stub file behind that looks identical to the original except for the actual size. Thanks, Wes...

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          This is possible because DiskXtender installs an extension to the file system called a a file system filter and uses blocks of data call Reparse Points. The reparse point is essentially a block of data attached to a file that describes additional attributes, or whatever else you want. When the file is opened or you get properties on it, the attached reparse point data is sent to the file system filter that understands it, then the filter gets to do whatever it needs to, like get the actual file from an offline storage device. Look here[^] for more information on Reparse Points. For more information on Installable File Systems, the documentation and SDKs are here[^]. RageInTheMachine9532

          W 1 Reply Last reply
          0
          • D Dave Kreskowiak

            This is possible because DiskXtender installs an extension to the file system called a a file system filter and uses blocks of data call Reparse Points. The reparse point is essentially a block of data attached to a file that describes additional attributes, or whatever else you want. When the file is opened or you get properties on it, the attached reparse point data is sent to the file system filter that understands it, then the filter gets to do whatever it needs to, like get the actual file from an offline storage device. Look here[^] for more information on Reparse Points. For more information on Installable File Systems, the documentation and SDKs are here[^]. RageInTheMachine9532

            W Offline
            W Offline
            WESHILL
            wrote on last edited by
            #5

            Thank Rage...This is exatly what I am looking for. One other question: Do you know how to access the DeviceIOControl in VB? All the examples I've seen so far are in C++. Thanks, Wes...

            W 1 Reply Last reply
            0
            • W WESHILL

              Thank Rage...This is exatly what I am looking for. One other question: Do you know how to access the DeviceIOControl in VB? All the examples I've seen so far are in C++. Thanks, Wes...

              W Offline
              W Offline
              WESHILL
              wrote on last edited by
              #6

              Hi, I gave the following a try but got nowhere. Could someone assist pls. ================================================================== Imports System.Runtime.InteropServices Private Declare Auto Function CreateFile Lib "kernel32" _ Alias "CreateFileA" ( _ ByVal lpFileName As FileInfo, _ ByVal hTemplate As Long, _ ByVal dwDesiredAccess As Long, _ ByVal dwShareMode As Long, _ ByVal lpSecurityAttributes As Long, _ ByVal dwCreationDisposition As Long _ ) As Long Public Declare Ansi Function DeviceIoControl Lib "kernel32" ( _ ByVal hFile As String, _ ByVal dwIoControlCode As Integer, _ ByVal lpInBuffer As Integer, _ ByVal nInBufferSize As Integer, _ ByVal lpOutBuffer As Integer, _ ByVal nOutBufferSize As Integer, _ ByRef lpBytesReturned As Integer, _ ByVal lpOverlapped As Integer) As Boolean Const CREATE_ALWAYS = 2 Const GENERIC_READ = &H80000000 Const GENERIC_WRITE = &H40000000 Sub command1_Click() dim h h = File.Open("d:\test.txt", FileMode.Create) DeviceIoControl(wes, FSCTL_SET_SPARSE, NULL, 0, NULL, 0, 84, 0) end sub ================================================================== Thanks...

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups