• The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
Menu
  • The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
  • Accessing File Member Timestamps from a .NET C# Program

    September 12, 2007 Hey, Mike

    I’m trying to use C# .Net to inspect the file create date and file modified date on member files in a custom library under QSys.Lib. Do you have any idea how to do this or can you suggest a place to start? Unfortunately, I code in C# and do not know RPG or CL commands.

    –GS

    We can tackle this problem without any server side logic. Fortunately, this job is pretty easy, thanks to IBM providing us with integration into the Windows world.

    The first thing you need to learn about is a special program called NetServer, which can be used to publish IFS files with the Windows world in the same way that you can publish a folder on a Windows server as a share. In other words, you can map a Windows share to a portion or the entirety of the IFS. For more info on configuring NetServer, take a look at this article.

    You will need to decide at which level you want to publish your IFS information. This all depends on whether you need to access data in a single library, in multiple files, in a single file, etc. Since you want to review member information for a database file, you will need to look in the portion of the IFS that points to the traditional System i/AS/400 storage area. This section of the IFS is called QSYS.LIB. Some of the options are:

    • /QSYS.LIB – share all of the libraries on the system. This is somewhat akin to publishing a share to the root of the C drive on your computer
    • /QSYS.LIB/YOURLIB.LIB – share a single library. This is analogous to publishing a single folder
    • /QSYS.LIB/ YOURLIB.LIB/YOURFILE.FILE – share a single file (including all of its members)

    You might have guessed that you need to substitute the real library name for YOURLIB and the real file name for YOURFILE.

    Of course, the broader the share level the more information you expose to the outside world, so be as restrictive as possible. You will create a security maintenance headache if you try to maintain too many shares! On the other hand, don’t expect that you’ll be able to do much with /QSYS.LIB objects from the Windows world other than read some of their attributes!

    Once you publish the share to QSYS.LIB at the appropriate level using NetServer, make sure Windows can access the share so that it is available in your program (either through a mapped drive or via connecting to the share programmatically).

    Now for the sample. Say we create a share to a source file and call the share QSOURCEFILE on system MYAS400. The UNC path to our share is:

    myas400qsourcefile

    (In the AS/400 world, a database file or source file can have multiple members. When mapped to a Windows share, each AS/400 file appears as a folder and each member within the file appears as a Windows type file with an extension of .MBR.) Figure 1 shows what a source file containing two source members (Q1 and Q2) looks like when published as a Windows share.

    Figure 1. Sample of a source file containing two source members (Q1 and Q2) when published as a Windows share.

    Once Windows is connected to the IFS share, try out this simple C# console program, which reads through a source file and retrieves the creation time and modification time of each source member.

    using System;
    using System.IO;
    
    namespace ConsoleApplication1
    {
      class Program
      {
        static void Main(string[] args)
        {
          string[] files = Directory.GetFiles(
                  @"myas400qsourcefile", "*.*");
          foreach (string file in files)
          {
            Console.WriteLine(file + " " +
              File.GetCreationTime(file) + " "+
              File.GetLastWriteTime(file));
          }
          Console.WriteLine("Completed");
          Console.ReadLine();
        }
      }
    }
    

    Keep in mind that IFS access can be relatively slow, especially when retrieving creation and update information, so access it wisely!

    For those wondering about an alternative server side approach, one alternative would be an SQL Table function created in RPG that will return information about the IFS to the .NET client via an ODBC or managed provider call. As always, there is more than one way to skin a cat.

    RELATED STORY

    Admin Alert: Three Steps to Mapping iSeries Data to a Windows Network Drive



                         Post this story to del.icio.us
                   Post this story to Digg
        Post this story to Slashdot

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Tags:

    Sponsored by
    ARCAD Software

    Embrace VS Code for IBM i Development

    The IBM i development landscape is evolving with modern tools that enhance efficiency and collaboration. Ready to make the move to VS Code for IBM i?

    Join us for this webinar where we’ll showcase how VS Code can serve as a powerful editor for native IBM i code and explore the essential extensions that make it possible.

    In this session, you’ll discover:

    • How ARCAD’s integration with VS Code provides deep metadata insights, allowing developers to assess the impact of their changes upfront.
    • The role of Git in enabling seamless collaboration between developers using tools like SEU, RDi, and VS Code.
    • Powerful extensions for code quality, security, impact analysis, smart build, and automated RPG conversion to Free Form.
    • How non-IBM i developers can now contribute to IBM i projects without prior knowledge of its specifics, while ensuring full control over their changes.

    The future of IBM i development is here. Let ARCAD be your guide!

    Watch Now

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Sponsored Links

    HiT Software:  DBMoto performs real-time as well as snapshot data replication
    COMMON:  Join us at the annual 2008 conference, March 30 - April 3, in Nashville, Tennessee
    NowWhatJobs.net:  NowWhatJobs.net is the resource for job transitions after age 40

    IT Jungle Store Top Book Picks

    The System i Pocket RPG & RPG IV Guide: List Price, $69.95
    The iSeries Pocket Database Guide: List Price, $59.00
    The iSeries Pocket Developers' Guide: List Price, $59.00
    The iSeries Pocket SQL Guide: List Price, $59.00
    The iSeries Pocket Query Guide: List Price, $49.00
    The iSeries Pocket WebFacing Primer: List Price, $39.00
    Migrating to WebSphere Express for iSeries: List Price, $49.00
    iSeries Express Web Implementer's Guide: List Price, $59.00
    Getting Started with WebSphere Development Studio for iSeries: List Price, $79.95
    Getting Started With WebSphere Development Studio Client for iSeries: List Price, $89.00
    Getting Started with WebSphere Express for iSeries: List Price, $49.00
    WebFacing Application Design and Development Guide: List Price, $55.00
    Can the AS/400 Survive IBM?: List Price, $49.00
    The All-Everything Machine: List Price, $29.95
    Chip Wars: List Price, $29.95

    IBM Spreads the developerWorks Love Through New ‘Gizmos’ EGL: The Future of Programming for the System i?

    Leave a Reply Cancel reply

Volume 7, Number 31 -- September 12, 2007
THIS ISSUE SPONSORED BY:

WorksRight Software
Help/Systems
Twin Data

Table of Contents

  • Reuse Deleted Records? *YES!
  • Accessing File Member Timestamps from a .NET C# Program
  • Admin Alert: A Primer for Changing Your i5/OS Startup Program
  • PHP: An Easy Yet Powerful Language Syntax
  • I Want My F15 Back!
  • Admin Alert: Magical & Mysterious iSeries Access CWB Programs

Content archive

  • The Four Hundred
  • Four Hundred Stuff
  • Four Hundred Guru

Recent Posts

  • Liam Allan Shares What’s Coming Next With Code For IBM i
  • From Stable To Scalable: Visual LANSA 16 Powers IBM i Growth – Launching July 8
  • VS Code Will Be The Heart Of The Modern IBM i Platform
  • The AS/400: A 37-Year-Old Dog That Loves To Learn New Tricks
  • IBM i PTF Guide, Volume 27, Number 25
  • Meet The Next Gen Of IBMers Helping To Build IBM i
  • Looks Like IBM Is Building A Linux-Like PASE For IBM i After All
  • Will Independent IBM i Clouds Survive PowerVS?
  • Now, IBM Is Jacking Up Hardware Maintenance Prices
  • IBM i PTF Guide, Volume 27, Number 24

Subscribe

To get news from IT Jungle sent to your inbox every week, subscribe to our newsletter.

Pages

  • About Us
  • Contact
  • Contributors
  • Four Hundred Monitor
  • IBM i PTF Guide
  • Media Kit
  • Subscribe

Search

Copyright © 2025 IT Jungle