fhg
Volume 7, Number 31 -- September 12, 2007

Accessing File Member Timestamps from a .NET C# Program

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

\\myas400\qsourcefile

(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(
              @"\\myas400\qsourcefile", "*.*");
      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


Sponsored By
HELP/SYSTEMS

Discover Robot/SECURITY, the i5/OS security monitoring
and auditing software, from Help/Systems

                                                            · Profile Exchange
                                                            · Exit Point Monitoring
                                                            · System Authority Auditing
                                                            · QAUDJRN Monitoring
                                                            · System Security Analysis

Robot/SECURITY is the only security software that
combines five critical System i security tools in one package.

Visit our Web site at http://www.helpsystems.com/400g-sec/
to learn more about Robot/SECURITY.


Senior Technical Editor: Ted Holt
Technical Editors: Howard Arner, Joe Hertvik, Shannon O'Donnell, Kevin Vandever
Contributing Technical Editors: Joel Cochran, Wayne O. Evans, Raymond Everhart,
Bruce Guetzkow, Brian Kelly, Marc Logemann, David Morris
Publisher and Advertising Director: Jenny Thomas
Advertising Sales Representative: Kim Reed
Contact the Editors: To contact anyone on the IT Jungle Team
Go to our contacts page and send us a message.

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


 
The Four Hundred
Supermegavirtualizationfest 2007

Reader Feedback on the Death of DB2/400 for Domino

Sirius Expands Northeast Presence with SCS Buy

As I See It: The Dons of Dialogue

The Linux Beacon
AMD Gets Aggressive About Watts with Quad-Core Barcelonas

NASA Buys Big Xeon-Linux Cluster from SGI

VMware Trims Down Hypervisor for Embedding in Servers

XenSource Offers Embedded Hypervisor for Servers

Four Hundred Stuff
SugarCRM Delivers 'Landmark' Release

Automating Database Encryption Expands Linoma's Portfolio

Services a Priority at ASNA after Merger with BluePhoenix

The Data Quality Inflection Point

Big Iron
PSI Adopts NEC Itanium Servers for Mainframe Clones

Top Mainframe Stories From Around the Web

Chats, Webinars, Seminars, Shows, and Other Happenings

System i PTF Guide
August 11, 2007: Volume 9, Number 32

August 4, 2007: Volume 9, Number 31

July 28, 2007: Volume 9, Number 30

July 21, 2007: Volume 9, Number 29

July 14, 2007: Volume 9, Number 28

July 7, 2007: Volume 9, Number 27

The Windows Observer
Microsoft Delays Windows Server 2008

Microsoft Preps Windows Vista SP1

ISO Rejects Microsoft's Open XML as Standard

The Data Quality Inflection Point

The Unix Guardian
The Left and Right Hands of Sun

Core Transition Complete as Intel Ships 'Tigerton' Xeon MPs

NetApp Sues Sun Over File System Patents

Mad Dog 21/21: Leverage

Four Hundred Monitor
Four Hundred Monitor's
Full iSeries Events Calendar

THIS ISSUE SPONSORED BY:

WorksRight Software
Help/Systems
Twin Data


Printer Friendly Version


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

Four Hundred Guru

BACK ISSUES

From the IT Jungle Forums
What's coalesce good for?

Duplicated printer files

Urgent Help Needed--Limit the result set in SQL stored procedure

Problem with "cpyfrmimpf"

FNDSTRPDM Output Member Name to *OUTFILE





 
Subscription Information:
You can unsubscribe, change your email address, or sign up for any of IT Jungle's free e-newsletters through our Web site at http://www.itjungle.com/sub/subscribe.html.

Copyright © 1996-2008 Guild Companies, Inc. All Rights Reserved.
Guild Companies, Inc., 50 Park Terrace East, Suite 8F, New York, NY 10034

Privacy Statement