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 7713349
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:51:13+00:00 2026-06-01T01:51:13+00:00

Under windows, this F# code will extend a file from say 12 bytes out

  • 0

Under windows, this F# code will extend a file from say 12 bytes out to 655346 bytes when the capacity argument (last argument) is set to a larger size than the underlying file. This seems to be the cleanest way to extend a memory mapped file. Under mono / linux it throws an ArgumentException: capacity unless the file is as long as the mapped capacity. Is there a clean way to get mono to extend the file or do I have to preextend the file before I can map?

let Main () =
    let path = "parts.pash"
    let l = 65536L
    let mm =    MemoryMappedFiles.MemoryMappedFile.CreateFromFile(path,FileMode.OpenOrCreate,"pashmap",l)

    ()

Main()

Error message

Unhandled Exception: System.ArgumentException: capacity at
System.IO.MemoryMappedFiles.MemoryMappedFile.CreateFromFile
(System.String path, FileMode mode, System.String mapName, Int64
capacity, MemoryMappedFileAccess access) [0x00000] in :0 at
System.IO.MemoryMappedFiles.MemoryMappedFile.CreateFromFile
(System.String path, FileMode mode, System.String mapName, Int64
capacity) [0x00000] in :0 at Program.Main ()
[0x00000] in :0 at
.$Program.main@ () [0x00000] in :0

Version of mono:

[daz@clowder pash]$ mono --version
Mono JIT compiler version 2.10.1 (tarball Mon Apr  4 10:40:52 PDT 2011)
Copyright (C) 2002-2011 Novell, Inc and Contributors. www.mono-project.com
        TLS:           __thread
        SIGSEGV:       altstack
        Notifications: epoll
        Architecture:  x86
        Disabled:      none
        Misc:          softdebug
        LLVM:          supported, not enabled.
        GC:            Included Boehm (with typed GC and Parallel Mark)

EDIT: it appears that the different underlying behaviour of memory mapping is exposed in the API so you need to extend the file yourself to the right length to be platform neutral

let f = File.Open(path,FileMode.Append,FileAccess.Write)
let pad = l- FileInfo(path).Length
let padding = Array.create (int32 pad) 0uy
f.Write(padding,0,int pad)
f.Close()
  • 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-06-01T01:51:14+00:00Added an answer on June 1, 2026 at 1:51 am

    Looking at the .NET implementation of CreateFromFile there is no implementation of that functionality. Other than argument checking, it is a slim wrapper around the Windows API call from what I can tell.

    For this reason the ability to create a larger file is more of a happy coincidence from the .NET land, so it is no surprise that Mono removed that ability if the underlying operating system does not allow similar functionality.

    Put more simply, not likely, since the .NET version doesn’t technically extend the file either, the Windows API does.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was under the impression that this code #include <windows.h> #include <stdio.h> int WINAPI
The following code will give a hard fail when run under Windows 7 32bit:
Under Windows there are some handy functions like QueryPerformanceCounter from mmsystem.h to create a
I am creating screenshots under Windows and using the LockBits function from GDI+ to
On http://code.google.com/p/modwsgi/ one can read this statement Daemon mode of mod_wsgi will however only
I have this code in a Java EE Application for reading the Properties file.
Here is a simple code of defining an array. I noticed this code will
Under Windows XP WPF true 3D content (which is usually displayed using the Viewport3D
Under Windows Server 2003, Enterprise Edition, SP2 (/3GB switch not enabled) As I understand
Under Windows Vista, when I check whether my current user account is in Administrators

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.