• 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:

    • Share on Reddit (Opens in new window) Reddit
    • Share on Facebook (Opens in new window) Facebook
    • Share on LinkedIn (Opens in new window) LinkedIn
    • Share on X (Opens in new window) X
    • Email a link to a friend (Opens in new window) Email

    Tags:

    Sponsored by
    JAMS Software

    One Scheduler. IBM i, Windows, Linux, and More.

    IBM i teams trust JAMS to schedule and orchestrate jobs across every platform in their environment. Centralized visibility, cross-platform dependency management, and alerts that reach the right person before the business feels it.

    Fewer than 5% of IBM i shops run IBM i only. The rest are managing cross-platform dependencies — often without a clear picture of how they connect. JAMS draws that map, enforces those dependencies automatically, and gives your team a single place to monitor, manage, and recover when something goes wrong.

    If you are running hundreds of CL scripts and custom RPG processes, bring them as-is. JAMS runs them exactly as they do today — except now they are visible, monitored, and part of an orchestrated workflow instead of scattered across folders only one person knows about.

    No consumption-based pricing. No surprise bills when your workload spikes. You pay based on how many machines JAMS talks to — that’s it.

    Learn More → https://jamsscheduler.com/lp/ibm-i

    Share this:

    • Share on Reddit (Opens in new window) Reddit
    • Share on Facebook (Opens in new window) Facebook
    • Share on LinkedIn (Opens in new window) LinkedIn
    • Share on X (Opens in new window) X
    • Email a link to a friend (Opens in new window) 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

    Reuse Deleted Records? *YES! Admin Alert: A Primer for Changing Your i5/OS Startup Program

    Leave a ReplyCancel 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

  • Big Blue Ships Bob 2.0 And Premium Package For IBM i
  • Your IBM i Jobs Don’t Live On An Island Anymore
  • FalconStor Creates Cloud Clean Room To Prove Backup Recoveries Work
  • Talking Git On IBM i With A Bunch Of IBM i Gits
  • IBM i PTF Guide, Volume 28, Number 22
  • More Power Systems Price Hikes, This Time They Are “Directional”
  • AI Is Not Just For Developers, It Is For Everyone At Your Company
  • Guru: Finding Data In The Forest – Exploring Three-Part Naming In SQL
  • Former IBMer’s New Book Puts The Midrange In The Spotlight
  • Have You Tried To Buy A Server Lately?

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