• 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
    New Generation Software

    FREE Webinar:

    Creating Great Data for Enterprise AI

    Enterprise AI relies on many data sources and types, but every AI project needs a data quality, governance, and security plan.

    Wherever and however you want to analyze your data, adopting modern ETL and BI software like NGS-IQ is a great way to support your effort.

    Webinar: June 26, 2025

    RSVP today.

    www.ngsi.com – 800-824-1220

    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

  • Public Preview For Watson Code Assistant for i Available Soon
  • COMMON Youth Movement Continues at POWERUp 2025
  • IBM Preserves Memory Investments Across Power10 And Power11
  • Eradani Uses AI For New EDI And API Service
  • Picking Apart IBM’s $150 Billion In US Manufacturing And R&D
  • FAX/400 And CICS For i Are Dead. What Will IBM Kill Next?
  • Fresche Overhauls X-Analysis With Web UI, AI Smarts
  • Is It Time To Add The Rust Programming Language To IBM i?
  • Is IBM Going To Raise Prices On Power10 Expert Care?
  • IBM i PTF Guide, Volume 27, Number 20

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